gpt4 book ai didi

asp.net - Visual Studio 2019 中多个帐户的 DefaultAzureCredential 异常

转载 作者:行者123 更新时间:2023-12-02 07:34:53 24 4
gpt4 key购买 nike

我遇到了以下情况并最终解决了问题:

我有一个 ASP.NET 应用程序,它通过 AzureKeyVaultConfigBuilder 对 Azure Key Vault 具有运行时依赖性。使用 Visual Studio 2019 从我的本地计算机运行,只要将我的工作 (@microsoft.com) 帐户添加到 Visual Studio,它就能够访问 Key Vault。但是,如果我将个人 Microsoft 帐户 (@live.com) 和工作帐户 (@microsoft.com) 添加到 Visual Studio,则应用程序会尝试使用我的个人 Microsoft 帐户 (@live.com) 对 Key Vault 进行身份验证),当它应该使用工作 (@microsoft.com) 帐户时。

当两个帐户都登录到 Visual Studio 时,我收到以下异常:

Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: The configBuilder 'AzureKeyVault' failed while processing the configuration section 'appSettings'.: Error in Configuration Builder 'AzureKeyVault'::GetValue(AzureStorageConnectionString)

Source Error:


Line 32: </builders>
Line 33: </configBuilders>
Line 34: <appSettings configBuilders="AzureKeyVault">
Line 35: <add key="AzureStorageConnectionString" value="" />
Line 36: </appSettings>

Source File: C:\<path to ASP.NET Web project>\web.config Line: 34


Click here to show additional error information:

Exception Details: Azure.Identity.CredentialUnavailableException: DefaultAzureCredential failed to retrieve a token from the included credentials.
EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
ManagedIdentityCredential authentication unavailable, no managed identity endpoint found.
SharedTokenCacheCredential authentication unavailable. Multiple accounts were found in the cache. Use username and tenant id to disambiguate.

最佳答案

我进行了大量的试验和错误,在环境变量级别、Visual Studio 级别和 Azure CLI 级别设置凭据,但是当在 Visual Studio 中注册多个帐户时,这些都没有得到尊重。

问题出在 Azure.Identity 包上,该包用于根据 Azure 开发环境对 ASP.NET 应用程序进行身份验证。我安装了 1.1.1 版本的软件包。并发调用 DefaultAzureCredential 时出现多个问题 have been fixed in versions 1.2.0 and 1.3.0 。因此,更新到版本 1.3.0 解决了我的问题并得到了适当的尊重 the setting of the VisualStudioCredential .

默认AzureCredential specifies a control flow从不同来源获取不同的身份验证 token 。

关于asp.net - Visual Studio 2019 中多个帐户的 DefaultAzureCredential 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65819014/

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