azure - 在 azure 中运行 powershell 脚本时无法获取租户组织的令牌
问题描述
我正在尝试从 powershell 连接到 azure 门户。我无法连接。以下是错误信息。Connect-AzAccount :无法再找到默认上下文;请运行“Get-AzContext -ListAvailable”以查看所有可用上下文,“Select-AzContext”选择新的默认上下文,或“Connect-AzAccount”以使用新帐户登录。在行:1 字符:1
- 连接-AzAccount
-
+ CategoryInfo : CloseError: (:) [Connect-AzAccount], PSInvalidOperationException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand
调试:AzureQoSEvent:CommandName - Connect-AzAccount;IsSuccess - 错误;持续时间 - 00:00:00.0390377;; 异常 - System.Management.Automation.PSInvalidOperationException:无法再找到默认上下文;请运行“Get-AzContext -ListAvailable”以查看所有可用上下文,“Select-AzContext”以选择新的默认上下文,或“Connect-AzAccount”以使用新帐户登录。在 Microsoft.Azure.Commands.Common.Authentication.Models.AzureRmProfile.get_DefaultContext() 在 Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient..ctor(IProfileOperations profile) 在 Microsoft.Azure.Commands.Profile.Common.AzureContextModificationCmdlet。修改上下文(动作2 contextAction) at Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.SetContextWithOverwritePrompt(Action
3 setContextAction) 在 Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand.ExecuteCmdlet() 在 Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord(); 调试:完成发送指标。调试:晚上 8:08:57 - ConnectAzureRmAccountCommand 结束处理。
解决方案
尝试运行
Clear-AzContext
如果再次遇到问题,请手动删除文件.Azure\AzureRMContext.json
并.Azure\AzureRmContextSettings.json
如果是 windows ,你会发现上面的文件夹/文件,c:\users\yourname\
或者如果它是 Linux /home/yourname/
推荐阅读
- javascript - 打字稿滚动位置
- android - React Native Android Build Failure - 配置项目':expo-image-loader'.java.lang.IllegalArgumentException时出现问题(无错误消息)
- python - 使用 Sphinx 记录 Django 项目
- javascript - 在 ReactJs 中自动上下滚动表格
- mongodb - Java - 使用 MongoDB 集合 bulkWrite 插入/更新
- terraform - Terraform 模块来源:目标最新版本和 GitHub 中的特定文件
- python - 如何使用功能供计算机选择
- r - 如何使用 ggplot2 将 Latitude_min、Latitude_max、Longitude_min 和 Longitude_max 绘制为网格/四边形形式?
- r - 来自不同包的两个功能不能一起工作
- file-upload - 雪花 - Azure 文件上传 - 如果文件大小超过 40MB,我如何对文件进行分区