gpt4 book ai didi

azure - DefaultAzureCredentials 无法在 MangedIdentity AKS 中获取凭据

转载 作者:行者123 更新时间:2023-12-03 00:59:16 30 4
gpt4 key购买 nike

基于给出的文档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 连接以获取值。但由于某种原因它抛出了这个错误。如果我遗漏了什么,请有人指导我。

最佳答案

Managed identity用于创建 AKS 群集的是控制平面,而不是工作节点或应用程序。控制平面使用该托管身份来创建请求的云资源,例如负载均衡器、规模集、路由等。如果您希望应用程序使用托管身份,建议的方法是部署 aad-pod-identities这为您提供了应用程序级别的授权方案。或者,您也可以启用 managed identity for the VMSS基于节点池。在后一种情况下,Azure 将为具有相同名称的节点池创建一个新的系统托管标识,您可以使用它在 KeyVault 或其他服务之间建立授权。

关于azure - DefaultAzureCredentials 无法在 MangedIdentity AKS 中获取凭据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63582171/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com