由于描述错误,无法从 PowerShell 连接 Azure 帐户

问题描述 投票:0回答:2

由于描述错误,无法从 PowerShell 连接 Azure 帐户。

PS C:\WINDOWS\system32> Connect-AzAccount
WARNING: Unable to acquire token for tenant '36ff3f25-cbe8-48b8-ba26-58974869160e'
WARNING: Unable to set default context 'Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureContext'.
Connect-AzAccount : Run Connect-AzAccount to login.
At line:1 char:1
+ Connect-AzAccount
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Connect-AzAccount], PSInvalidOperationException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand

如何解决这个问题?

azure azure-powershell
2个回答
0
投票

如果之前运行正常,建议手动删除

AzureRMContext.json
AzureRmContextSettings.json
这两个文件。您可以在
C:\Users\Administrator\.azure\
文件夹中找到它们。或者运行命令
Clear-AzContext


0
投票

我遇到过类似的错误消息

Connect-AzAccount -环境 AzureChinaCloud

WARNING: Unable to acquire token for tenant 'xxxxxxxxxxxxxxxxxxxx' with error 'SharedTokenCacheCredential authentication unavailable. No account matching the specified username: [email protected] tenantId: xxxxxxxxxxxxxxxxxxxx was found in the cache.'
WARNING: Unable to set default context 'Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureContext'

Jason的回复给了我提示。我已经清理了缓存文件,它可以正常工作。

这是我做的

  1. 转到 C:\Users\AppData\Local.IdentityService,删除“msal.cache”
  2. 转到 C:\Users.Azure,删除 4 个文件“azureProfile.json”、“azureRmcontext.json”、“azureRmsurvey.json”和“clouds.config”
  3. 关闭 VSCode 并重新安装 VSCode。

现在,VScode 终端让我登录。

希望能帮到你。

© www.soinside.com 2019 - 2024. All rights reserved.