【发布时间】:2020-10-08 03:46:09
【问题描述】:
当我尝试从本地计算机访问 Key Vault 时遇到以下错误
DefaultAzureCredential()
我正在运行以下两行,但我不断收到错误。
client = SecretClient(vault_url=<URL>, credential=DefaultAzureCredential())
secret = client.get_secret(<SECRET NAME>).value
azure.core.exceptions.ClientAuthenticationError: DefaultAzureCredential failed to retrieve a token from the included credentials.
Attempted credentials:
EnvironmentCredential: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
ManagedIdentityCredential: ManagedIdentityCredential authentication unavailable, no managed identity endpoint found.
SharedTokenCacheCredential: SharedTokenCacheCredential authentication unavailable. No accounts were found in the cache.
VisualStudioCodeCredential: Azure Active Directory error '(invalid_grant) AADSTS700082: The refresh token has expired due to inactivity. The token was issued on 2020-06-07T03:58:48.4708462Z and was inactive for 90.00:00:00.
我尝试通过以下方式登录 Azure
az login
但这不会刷新凭据。
编辑: 我尝试了documentation 中的一些其他配置。 Azure CLI 凭据的工作似乎很奇怪,因为它看起来像是由默认凭据处理的场景之一。
【问题讨论】:
-
您是否尝试过使用
AzureCliCredential()而不是DefaultAzureCredential()? -
谢谢,@PamelaPeng - 那工作。知道为什么 CLI 凭证在默认凭证不起作用时起作用吗?根据documentation,CLI 似乎是 Default 考虑的情况之一。
标签: azure azure-keyvault