97
votes

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:

enter image description here

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

6 Answers

204
votes

For Azure CLI 2.0 (preview) I had to use

az account set --subscription <name or id>
22
votes

Please try the following:

azure account set -s {Subscription Id}

That should change the subscription.

6
votes
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>
5
votes

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"
3
votes

Use id (subscription id) that is GUID, which will be listed when you did az login

enter image description here

And then execute the below command..

az account set --subscription fffde5cb-cccc-aaaa-eee-457c3292608e
2
votes

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.