azure_secret
Azure secret are used to fetch the secret.
clear_cache()
Clears the cache of retrieved secrets. This can be used to force a re-fetch of secrets from the Key Vault.
Example
clear_cache()
Source code in physical_operations_utils/azure_utils/azure_secret.py
60 61 62 63 64 65 66 67 68 69 | |
get_secret(secret_name)
Retrieves a secret from an Azure Key Vault. Uses a cache to avoid duplicate calls to the same Key Vault.
This function:
1. Reads the KEY_VAULT_NAME environment variable to determine the Key Vault URL.
2. Authenticates using Azure's DefaultAzureCredential.
3. Retrieves the specified secret from the Key Vault.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
secret_name
|
str
|
The name of the secret to retrieve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The value of the retrieved secret. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the |
ResourceNotFoundError
|
If the secret does not exist in the Key Vault. |
ClientAuthenticationError
|
If authentication fails. |
Example
secret_value = get_secret("my-secret")
print(secret_value)
Source code in physical_operations_utils/azure_utils/azure_secret.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |