Azure Cli 如何更改订阅默认值
Azure Cli how to change subscription default
我的 Azure 帐户中有 3 个订阅,我需要更改默认订阅。当我 运行 命令时:
azure account list
我有这个输出:
我曾尝试通过这种方式更改默认或当前订阅,但没有结果...
azure config set subscription {{MyIdSubscription}}
有什么想法吗?谢谢
请尝试以下操作:
azure account set -s {Subscription Id}
那应该更改订阅。
对于 Azure CLI 2.0(预览版)我不得不使用
az account set --subscription <name or id>
使用 id(订阅 ID)即 GUID,当您这样做时会列出 az login
然后执行下面的命令..
az account set --subscription fffde5cb-cccc-aaaa-eee-457c3292608e
在这个 way.it 中尝试对我有用,可以将 Azure PowerShell 设置为特定的 Azure 订阅
Set-AzContext -SubscriptionId "t666-e251-49ce-a1cd-5c3144"
重要提示!
小心混合 Azure Shell 和 Powershell - 例如。 “az 登录”和“Connect-AzAccount”
如果您使用“az login”,它不会反映在像 Get-AzContext 这样的命令上。
因此,如果您有依赖于 Get-AzContext 的 powershell 脚本,它们将会失败。
1. List all the subscriptions you have
az account list --output table
Name CloudName SubscriptionId State IsDefault
--------------- ------------ ---------------- --------- ----------
AssociateProd AzureCloud xxxxxxxxxxxx Enabled False
2. Pick the subscription you want and use it in the command below.
az account set --subscription <subscription_id>
我的 Azure 帐户中有 3 个订阅,我需要更改默认订阅。当我 运行 命令时:
azure account list
我有这个输出:
我曾尝试通过这种方式更改默认或当前订阅,但没有结果...
azure config set subscription {{MyIdSubscription}}
有什么想法吗?谢谢
请尝试以下操作:
azure account set -s {Subscription Id}
那应该更改订阅。
对于 Azure CLI 2.0(预览版)我不得不使用
az account set --subscription <name or id>
使用 id(订阅 ID)即 GUID,当您这样做时会列出 az login
然后执行下面的命令..
az account set --subscription fffde5cb-cccc-aaaa-eee-457c3292608e
在这个 way.it 中尝试对我有用,可以将 Azure PowerShell 设置为特定的 Azure 订阅
Set-AzContext -SubscriptionId "t666-e251-49ce-a1cd-5c3144"
重要提示! 小心混合 Azure Shell 和 Powershell - 例如。 “az 登录”和“Connect-AzAccount” 如果您使用“az login”,它不会反映在像 Get-AzContext 这样的命令上。 因此,如果您有依赖于 Get-AzContext 的 powershell 脚本,它们将会失败。
1. List all the subscriptions you have
az account list --output table
Name CloudName SubscriptionId State IsDefault
--------------- ------------ ---------------- --------- ----------
AssociateProd AzureCloud xxxxxxxxxxxx Enabled False
2. Pick the subscription you want and use it in the command below.
az account set --subscription <subscription_id>