用于解决刷新令牌错误的 Azure CLI 命令

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

需要将哪些特定语法或命令添加到下面的 Azure CLI 命令序列中,才能消除

AADSTS700082
错误的根本原因,以便命令可以正常运行?

幕后到底发生了什么导致了这个看似毫无意义的错误?

C:\path\to\dir>az login --service-principal -u long-alpha-numeric-id -p long-pass-word --tenant 88888888-4444-4444-4444-121212121212  
[  
  {  
    "cloudName": "AzureCloud",
    "homeTenantId": "88888888-4444-4444-4444-121212121212",
    "id": "11111111-1111-1111-1111-111111111111",
    "isDefault": true,
    "managedByTenants": [],
    "name": "SomeName",
    "state": "Enabled",
    "tenantId": "88888888-4444-4444-4444-121212121212",
    "user": {
      "name": "long-alpha-numeric-id",
      "type": "servicePrincipal"
    }
  },
  {
    "cloudName": "AzureCloud",
    "homeTenantId": "88888888-4444-4444-4444-121212121212",
    "id": "22222222-2222-2222-2222-222222222222",
    "isDefault": false,
    "managedByTenants": [],
    "name": "AnotherName",
    "state": "Enabled",
    "tenantId": "88888888-4444-4444-4444-121212121212",
    "user": {
      "name": "long-alpha-numeric-id",
      "type": "servicePrincipal"
    }
  }
]  

C:\path\to\dir>az account set --subscription 12345678-1234-1234-1234-123456789012

C:\path\to\dir>az group create --name myRG --location eastus
AADSTS700082: The refresh token has expired due to inactivity. The token was issued on 2023-05-04T21:19:28.1452801Z and was inactive for 90.00:00:00. Trace ID: 87654321-4321-4321-4321-210987654321 Correlation ID: 80808080-4040-4040-4040-121212121212 Timestamp: 2023-11-14 01:23:55Z    
Interactive authentication is needed. Please run:
az login --scope https://management.core.windows.net//.default  

秘密

long-pass-word
对于 ID 为
long-alpha-numeric-id
的服务主体来说是有效且最新的。我在 Azure 门户的 Entra 目录中确认了这一点。

az login --service-principal -u long-alpha-numeric-id -p long-pass-word --tenant 88888888-4444-4444-4444-121212121212
命令似乎运行成功,如上所示。

当向其中传递有效的订阅 ID 时,

az account set --subscription 12345678-1234-1234-1234-123456789012
命令也可以正常运行,不会出现错误。

但是

az group create --name myRG --location eastus
命令会抛出
AADSTS700082
错误,如果您滚动到上面 OP 中输出的底部,您可以看到。

什么给予?

这需要完全自动化运行,因此我们无法尝试错误消息中建议的交互式身份验证。

azure azure-active-directory azure-cli refresh-token
1个回答
0
投票

AADSTS700082:刷新令牌由于不活动而已过期。该代币于 2023-05-04T21:19:28.1452801Z 发行,并在 90.00:00:00 内处于非活动状态。跟踪 ID:87654321-4321-4321-4321-210987654321 关联 ID:80808080-4040-4040-4040-121212121212 时间戳:2023-11-14 01:23:55Z 需要交互式身份验证。请运行:az login --scope https://management.core.windows.net//.default

如果刷新令牌已过期,通常会发生该错误,要解决该错误,您需要重新运行

az
登录。

在您的情况下,错误是由于需要注销的现有

az
会话造成的。

因此要解决错误,请执行

az logout
并重新运行命令:

az logout

az login --service-principal -u ClientID -p ClientSecret --tenant TenantID

az account set --subscription SubscriptionID

az group create --name RukRG --location eastus

enter image description here

资源组创建成功:

enter image description here

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