【问题标题】:DefaultAzureCredential exception with multiple accounts in Visual Studio 2019Visual Studio 2019 中多个帐户的 DefaultAzureCredential 异常
【发布时间】:2021-04-25 09:02:59
【问题描述】:

我遇到了以下情况,最终发现了问题:

我有一个 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.

【问题讨论】:

    标签: asp.net visual-studio azure azure-web-app-service identity


    【解决方案1】:

    我经历了很多试错,在环境变量级别、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

    DefaultAzureCredential specifies a control flow 从各种来源获取不同的身份验证令牌。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-14
      • 2020-09-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多