DefaultAzureCredentials无法在MangedIdentity AKS中获取凭据

问题描述

基于给定的文档here。使用DefaultAzureCredentials()时,它将先检查环境变量,然后检查ManagedIdentity等。在测试中,我已经部署了系统托管服务身份AKS。我已经部署了一个c#应用程序,该应用程序尝试使用以下代码通过应用程序连接到Keyvault

   var keyClient = new KeyClient(vaultUri: new Uri(keyVaultUrl),credential: new DefaultAzureCredential(true));
        

        Response<KeyVaultKey> response = keyClient.GetKey("somekey"); 

将我的应用程序部署到AKS集群时,它失败并显示以下错误-

Unhandled exception. Azure.Identity.AuthenticationFailedException: DefaultAzureCredential failed to retrieve a token from the included credentials.
- EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
- ManagedIdentityCredential authentication unavailable. The requested identity has not been assigned to this resource.
Status: 400 (Bad Request)
Content:
{"error":"invalid_request","error_description":"Identity not found"}

基于文档,我的应用程序应该从AKS集群中获取托管身份,并能够与Keyvault连接以获取值。但是由于某种原因,它会抛出此错误。如果我错过了什么,请有人指导我。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)