0

我正在使用ChainedTokenCredential并尝试在本地调试环境中使用Visual Studio 2019. 在 Windows 终端中,我已经使用Azure CLI az login.

var credential = new ChainedTokenCredential(
                    new ManagedIdentityCredential(),
                                new AzureCliCredential());

var token = await credential .GetTokenAsync(new TokenRequestContext(new[] { _configuration.GetSection("scope").Value }));

当我在调试中运行代码时,我看到以下错误,

ChainedTokenCredential 未能从包含的凭据中检索令牌。ManagedIdentityCredential 身份验证不可用。未找到托管身份端点。请运行“az login”来设置帐户

我需要在哪里做az login?谢谢。

4

1 回答 1

0

先执行az logout再试az login,我建议通过执行设置默认订阅az account set -s "Subscription ID"

于 2021-12-01T08:23:19.787 回答