Need a way to connect to Azure Keyvaluat Secret programatically using Python. Found existing doc from Azure which is pointing to usage of DefaultAzureCredential from azure.identity. Which explicitly seeks the enivironment to set up to have values link to git hub
Wanted those to be injected manually, instead setting them as Env Variable
最佳答案
One can use the below class from azure.identity i.e ClientSecretCredential, find the below code ex: snippet
from azure.identity import ClientSecretCredential
from azure.keyvault.secrets import SecretClient
TENANT= <TenantId-in-string>
CLIENT_ID = <ClientId-in-string>
CLIENT_SECRET= <ClientSecret-in-string>
credential = ClientSecretCredential(TENANT,CLIENT_ID,CLIENT_SECRET)
VAULT_URL= <AzureVault-url-in-string>
client = SecretClient(vault_url=VAULT_URL, credential=credential)
print(client)
example_secret = client.get_secret(<secret_name_in_string>)
print(example_secret.value)
关于python - 使用 Python、Azure Key Vault Secret Client 以编程方式连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69884235/