Set Azure PowerShell to a specific Azure Subscription

If you have multiple Azure Subscriptions, when you login you get a default subscription set, so if you try and take any actions on a feature in another subscription you would get error.  So you need to set the correct subscription.

To set the Subscription in PowerShell so you can run cmdlets against those features, perform the following:

  • Login via PowerShell

  • Set the current subscription context

Login via PowerShell

Enter Login-AzAccount and hit enter, then provide your user id and password

Get-AzureSubscription (this will give you the list of subscription)

Set the current subscription context

Select-AzureRmSubscription -SubscriptionId xxxxx-xxxxx-xxxxxx-xxxx (this way you can set which particular subscription you want to use)

One thought on “Set Azure PowerShell to a specific Azure Subscription

  1. Thanks for this post. It was helpful the first time I searched for this action. A quick update from me after further research some days later:
    Microsoft now recommends using the Az Module in PowerShell. The applicable new commands would be:
    1. Select-AzSubscription -Subscription “xxxx-xxxx-xxxx-xxxx”
    2. Set-AzContext
    The first option is an alias for the second and both options work.

    Like

Leave a comment