azure-powershell - Get-AzResourceGroup 返回“在上下文中找不到租户”
问题描述
我刚刚打开 PowerShell 并运行:
> Connect-AzAccount
> Get-AzResourceGroup
并收到此错误。
Get-AzResourceGroup:在上下文中找不到租户。请确保您提供的凭据有权访问 Azure 订阅,然后运行 Connect-AzAccount 登录。
> Get-AzSubscription
警告:无法为租户“Common”获取令牌
Get-AzSubscription:无法向租户进行身份验证。请确保您的帐户有权访问此租户并使用 Connect-AzAccount 登录
我已经有一年没有使用 Azure PowerShell了。我将连接命令给我的 URL 复制粘贴到同一个浏览器中,因为我打开了 Azure 订阅并照常登录。我是 Azure 子系统的唯一管理员和用户。这是我的版本。
> $PSVersionTable.PSVersion
Major Minor Patch PreReleaseLabel BuildLabel
----- ----- ----- --------------- ----------
7 1 4
我试图重新安装 Azure PowerShell 模块,但更加陌生。
> Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force
Install-Package: C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:9711
Line |
9711 | … talledPackages = PackageManagement\Install-Package @PSBoundParameters | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Administrator rights are required to install or update. Log on to the computer with an account that has Administrator rights, and then try again, or install by
| adding "-Scope CurrentUser" to your command. You can also try running the Windows PowerShell session with elevated rights (Run as Administrator).
显然,我以管理员身份运行并且我已经指定了CurrentUser
范围。我将放弃并尝试 Azure CLI。
在 GitHub 上提出问题:https ://github.com/Azure/azure-powershell/issues/15842
解决方案
我认为安装 Azure CLI 解决了它。
自发布以来,我实际上只做过这些事情。
- 安装了 Google Cloud CLI 和 GCP SDK。
- 花 10 个小时阅读 GCP 文档,了解一堆东西,因为我很想看看他们的草到底有多绿。
- 根据 Github 问题上的某人的要求,尝试安装不同的 Az PS 包但失败。
- 尝试并成功安装了 Microsoft.Graph PS 包,再次作为我的 Github 朋友要求的测试。
- 通过 MSI 安装了 Azure CLI。
- 阅读@BhargaviAnnadevara 的评论并尝试了一下,发现一切正常。
推荐阅读
- javascript - Array.prototype.isPrototypeOf 和 Array.isPrototypeOf 有什么区别?
- matrix - 如何生成每个单独的行和列的总和为零的矩阵
- android - 如何制作一个自动化拼车/餐厅应用请求的应用(例如 mystro)
- python - 找不到 TIFF 头文件(python 上的 tifflib 错误 - Ubuntu 20.04)
- azure - 如何在 ARM 模板中创建 Key Vault 托管存储帐户?
- html - 如何在 CSS 中选择包裹的 flex 行的最后一项
- html - 我怎样才能使按钮正确,修复中间部分并使所有内容都可以调整大小
- javascript - 使用动态模式验证时,响应式表单始终无效
- rasa - 如何以 rasa 形式启动 rasa 动作
- php - 如果我为已在购物车中的产品单击“添加到购物车”按钮,如何重定向到购物车页面