Visual Studio 2019 年多个帐户的 DefaultAzureCredential 异常
DefaultAzureCredential exception with multiple accounts in Visual Studio 2019
我 运行 进入以下场景并最终解决了问题:
我有一个 ASP.NET 应用程序,它通过 AzureKeyVaultConfigBuilder 对 Azure Key Vault 具有运行时依赖性。 运行 从我的本地计算机使用 Visual Studio 2019,如果只有我的工作 (@microsoft.com) 帐户被添加到 Visual Studio,它就能够访问 Key Vault。但是,如果我将我的个人 Microsoft 帐户 (@live.com) 和我的工作帐户 (@microsoft.com) 添加到 Visual Studio,应用程序会尝试使用我的个人帐户对 Key Vault 进行身份验证Microsoft 帐户 (@live.com),当它应该使用工作 (@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 级别设置凭据,但是 none在 Visual Studio.
中注册了多个帐户
问题出在 Azure.Identity 包上,该包用于针对 Azure 开发环境验证 ASP.NET 应用程序。我安装了 1.1.1 版本的软件包。并发调用 DefaultAzureCredential have been fixed in versions 1.2.0 and 1.3.0. As such, updating to version 1.3.0 solved my issue and properly respected the setting of the VisualStudioCredential.
的多个问题
DefaultAzureCredential specifies a control flow 从各种来源获取不同的身份验证令牌。
我 运行 进入以下场景并最终解决了问题:
我有一个 ASP.NET 应用程序,它通过 AzureKeyVaultConfigBuilder 对 Azure Key Vault 具有运行时依赖性。 运行 从我的本地计算机使用 Visual Studio 2019,如果只有我的工作 (@microsoft.com) 帐户被添加到 Visual Studio,它就能够访问 Key Vault。但是,如果我将我的个人 Microsoft 帐户 (@live.com) 和我的工作帐户 (@microsoft.com) 添加到 Visual Studio,应用程序会尝试使用我的个人帐户对 Key Vault 进行身份验证Microsoft 帐户 (@live.com),当它应该使用工作 (@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 级别设置凭据,但是 none在 Visual Studio.
中注册了多个帐户问题出在 Azure.Identity 包上,该包用于针对 Azure 开发环境验证 ASP.NET 应用程序。我安装了 1.1.1 版本的软件包。并发调用 DefaultAzureCredential have been fixed in versions 1.2.0 and 1.3.0. As such, updating to version 1.3.0 solved my issue and properly respected the setting of the VisualStudioCredential.
的多个问题DefaultAzureCredential specifies a control flow 从各种来源获取不同的身份验证令牌。