繁体   English   中英

使用 Python,Azure KeyVault Secret Client 以编程方式连接

[英]Using Python, Azure KeyVault Secret Client connecting programatically

需要一种使用 Python 以编程方式连接到 Azure Keyvaluat Secret 的方法。 从 Azure 找到现有文档,该文档指向 azure.identity 中 DefaultAzureCredential 的使用。 其中明确寻求环境设置以将值链接到 git hub

在此处输入图片说明

在此处输入图片说明

希望手动注入它们,而不是将它们设置为环境变量

可以使用 azure.identity 中的以下类,即ClientSecretCredential ,找到以下代码,例如: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)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM