我当前的设置:
我的 DevOps 人员已创建用户管理身份并将其添加到 Azure key 保管库的访问策略中。
我创建了一个函数应用 testing-01
并在平台设置下为其分配了 User-ManagedIdentity。
我使用 Python 3.6 作为运行时语言。
这是我的辅助方法,我用它来检查是否能够从 key 保管库访问 secret 。 我正在回复它的回复。
def cred_checker():
credential = ManagedIdentityCredential()
# credential = ManagedIdentityCredential(client_id='client_id
vault_name= "myvault"
client = SecretClient(vault_url=f"https://{vault_name}.vault.azure.net/", credential=credential)
username = client.get_secret(name="username")
password= client.get_secret(name="password")
return f"AKV client created successfully {client} .<br> name: {username},<br> pass: {password} "
我能够毫无错误地创建客户端。但是当我尝试从中获取 secret 时,我收到此 ClientAuthenticationError :
Exception while executing function: Functions.HttpTriggerFunc <--- Result: Failure Exception: ClientAuthenticationError: Unexpected response '{'statusCode': 400, 'message': 'Unable to load requested managed identity.', 'correlationId': '92daf146-fed2-4a75-8359-9r955939815e'}'
最佳答案
当您使用用户分配的身份时,您需要指定 client_id
ManagedIdentityCredential()
中的 MSI .
credential = ManagedIdentityCredential(client_id="xxxxxxxx")
要获取 client_id
,请导航到您的函数应用 -> Identity
-> 用户分配
-> 单击您的用户分配的身份 -> 复制 client_id
。
关于python - 如何使用 Azure Cloud Function (python) 中的用户管理身份向 Azure KeyVault 发出请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58765739/