Azure Cli How to Change Subscription Default

Azure Cli How to Change Subscription Default

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

Please try the following:

azure account set -s {Subscription Id}

That should change the subscription.

2
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"
0

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
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

David Miller
Author

David Miller

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.