问题描述
在Azure Databricks上获取Azure Key Vault中所存储的机密(secret)的两种方式?
问题解答
方式一: 在Databricks的Notebook 中,直接编写Python代码读取Key Vault的Secret
实例代码如下:
import os from azure.keyvault.secrets import SecretClient from azure.identity import DefaultAzureCredential KVUri = f"https://<your key vault name>.vault.azure.cn/" credential = DefaultAzureCredential() client = SecretClient(vault_url=KVUri, credential=credential) retrieved_secret = client.get_secret("<your secret name>") print(f"Your secret is '{retrieved_secret.value}'.")
10-10 03:02