azure - 错误: We don't have a valid access azure with Azure CLI

标签 azure azure-cli

我是 Azure CLI 的新用户。所以,我昨天开始使用它。一切正常,直到我在控制台上收到一条消息,要求我使用 Azure 登录命令再次登录。

我按照消息所说的做了。打开我的浏览器并输入代码。浏览器加载页面,一切正常。但是,当我进入控制台窗口时,我收到以下消息:

error:   We don't have a valid access token. Please run "azure login" again.
info:    Error information has been recorded to C:\Users\julia\.azure\azure.err
error:   login command failed

on the detail error file, this is the content:
2015-12-09T14:25:39.477Z - info:    Executing command login
2015-12-09T14:25:40.278Z - info:    To sign in, use a web browser to open the page aka.ms/devicelogin. Enter the code FYEBRSSSW to authenticate. If you're signing in as an Azure AD application, use the --username and --password parameters.
2015-12-09T14:25:40.278Z - verbose: code response from AAD is :{"userCode":"FYEBRSSSW","deviceCode":"FAAABAAEAiL9Kn2Z27UubvWFPbm0gLSP06OmChH0nnUbKKbL9_GLsujCsreUiKWZtv3DBNS6o5dK7vblnGRAk_b_3oO64FJ9f6Dd306_5P_ZlMUwIPCD-a02NydqTyYXXXXXXX","verificationUrl":"aka.ms/devicelogin","expiresIn":900,"interval":5,"message":"To sign in, use a web browser to open the page https://aka.ms/devicelogin. Enter the code FYEBRSSSW to authenticate. If you're signing in as an Azure AD application, use the --username and --password parameters."}
2015-12-09T14:36:25.449Z - error:   We don't have a valid access token. Please run "azure login" again.
2015-12-09T14:36:25.451Z - silly:   {
2015-12-09T14:36:25.451Z - silly:       stack: "Error: We don't have a valid access token. Please run "azure login" again.\n    at _polishError (C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI\\lib\\util\\authentication\\adalAuthForUser.js:64:10)\n    at C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI\\lib\\util\\authentication\\adalAuthForUser.js:48:25\n    at C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI\\lib\\util\\authentication\\token-cache.js:96:9\n    at C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI\\node_modules\\async\\lib\\async.js:52:16\n    at C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI\\node_modules\\async\\lib\\async.js:272:32\n    at C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI\\node_modules\\async\\lib\\async.js:44:16\n    at C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI\\lib\\util\\authentication\\win-token-storage.js:169:16\n    at C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI\\node_modules\\async\\lib\\async.js:697:13\n    at C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI\\node_modules\\async\\lib\\async.js:52:16\n    at C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI\\node_modules\\async\\lib\\async.js:272:32",
2015-12-09T14:36:25.452Z - silly:       message: "We don't have a valid access token. Please run "azure login" again.",
2015-12-09T14:36:25.452Z - silly:       __frame: {
2015-12-09T14:36:25.452Z - silly:           name: '__1',
2015-12-09T14:36:25.452Z - silly:           line: 47,
2015-12-09T14:36:25.452Z - silly:           file: 'C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI\\lib\\commands\\login.js',
2015-12-09T14:36:25.452Z - silly:           prev: undefined,
2015-12-09T14:36:25.452Z - silly:           calls: 0,
2015-12-09T14:36:25.452Z - silly:           active: false,
2015-12-09T14:36:25.452Z - silly:           offset: 53,
2015-12-09T14:36:25.452Z - silly:           col: 27
2015-12-09T14:36:25.452Z - silly:       },
2015-12-09T14:36:25.452Z - silly:       rawStack: " token. Please run "azure login" again.\n    at _polishError (C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI\\lib\\util\\authentication\\adalAuthForUser.js:64:10)\n    at C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI\\lib\\util\\authentication\\adalAuthForUser.js:48:25\n    at C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI\\lib\\util\\authentication\\token-cache.js:96:9\n    at C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI\\node_modules\\async\\lib\\async.js:52:16\n    at C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI\\node_modules\\async\\lib\\async.js:272:32\n    at C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI\\node_modules\\async\\lib\\async.js:44:16\n    at C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI\\lib\\util\\authentication\\win-token-storage.js:169:16\n    at C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI\\node_modules\\async\\lib\\async.js:697:13\n    at C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI\\node_modules\\async\\lib\\async.js:52:16\n    at C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI\\node_modules\\async\\lib\\async.js:272:32"
2015-12-09T14:36:25.452Z - silly:   }
2015-12-09T14:36:25.458Z - info:    Error information has been recorded to C:\Users\julia\.azure\azure.err

当我加入门户时,一切都很好,我的帐户处于事件状态,我可以毫无问题地创建和监控我的所有计算机。这是 Azure CLI v2.8 的特殊情况。

顺便说一下,我尝试了“azure logout 和 azure clear -q”命令,但没有成功。

最佳答案

如果您有多个 Azure 帐户,通常会发生这种情况。我的意思是这是一个浏览器->缓存/cookies问题。

您应该打开一个私有(private)浏览器 session ,甚至使用另一个浏览器并使用控制台 CLI 提供的链接启动一个新 session 。

这应该有效!

关于azure - 错误: We don't have a valid access azure with Azure CLI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34181800/

相关文章:

azure - 使用 Azure 2.0 CLI 预配 Azure Kubernetes ACS 集群

linux - 将 Azure CLI 命令的输出存储为变量

azure - 通过 Azure CLI 向资源分配多个标签会在使用变量时产生一个大标签

azure - 将本地 Docker 日志获取到 Azure 日志分析

c# - Azure表存储异常处理

c# - HTTP 触发器不返回 Azure Functions v2 中的堆栈跟踪

yaml - Azure CLI - VSTS - Yaml - 似乎只执行了脚本的第一行

azure - az ml dataset create 上的“create”拼写错误或未被系统识别

azure - 为什么我在为 Runbook 创建 Webhook 时收到授权失败异常?

sql-server - 无法在 SQL Azure 数据库上启用查询存储