I was trying to accessing my key vault, but I got always the same error:
AppServiceCredential.get_token failed: request() got an unexpected keyword argument 'tenant_id'
ManagedIdentityCredential.get_token failed: request() got an unexpected keyword argument 'tenant_id'
This was the code I used in an Azure Machine Learning notebook, copied from the docs:
from azure.identity import ManagedIdentityCredential
from azure.keyvault.secrets import SecretClient
credential = ManagedIdentityCredential()
secret_client = SecretClient(vault_url="https://XXXX.vault.azure.net/", credential=credential)
secretName = 'test'
retrieved_secret = secret_client.get_secret(secretName) # here's the error
retrieved_secret
What is wrong? Could you help me? Thank you in advance.
CodePudding user response:
This error is because of a bug that has since been fixed in azure-identity
's ManagedIdentityCredential
. Key Vault clients in recent packages include a tenant ID in token requests to support cross-tenant authentication, but some azure-identity
credentials didn't correctly handle this keyword argument until the bug was fixed in version 1.8.0. Installing azure-identity
>=1.8.0 should fix the error you're getting.
(Disclaimer: I work for the Azure SDK for Python)