I have 3 subscription in my Azure Account, I need to change the default subscription. When i Run the command:
azure account list
I have this output:
I have tried to change the default or current subscription on this way, with no results...
azure config set subscription {{MyIdSubscription}}
Any ideas? Thanks.
6 Answers
For Azure CLI 2.0 (preview) I had to use
az account set --subscription <name or id>
Please try the following:
azure account set -s {Subscription Id}
That should change the subscription.
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>
Try in this way.it worked for me to set Azure PowerShell to a specific Azure Subscription
Set-AzContext -SubscriptionId "t666-e251-49ce-a1cd-5c3144"
Use id (subscription id) that is GUID, which will be listed when you did az login
And then execute the below command..
az account set --subscription fffde5cb-cccc-aaaa-eee-457c3292608e
An important tip! Be careful mixing Azure Shell and Powershell - eg. "az login" and "Connect-AzAccount" If you use "az login" it will not reflect on commands like Get-AzContext. So if you have powershell scripts that depend on Get-AzContext they'll fail.