How To Set Subscription In Azure PowerShell

When you have multiple Azure Subscriptions, you can set your default subscription using PowerShell. In this article, let me walk you through the quick steps to set Azure subscription in powershell.

How To Set Subscription In Azure PowerShell

To set subscription in Azure PowerShell, follow the below steps.

1. Open PowerShell ISE with Run As Administrator mode.

set azure subscription in powershell

2. Run the below PowerShell command to get your Azure subscriptions list.

Get-AzSubscription

After executing the above Get-AzSubscription command, I successfully got the Azure subscriptions list, as shown below.

how to set azure subscription in powershell

3. we can now use the Set-AzContext command along with the subscription name or ID to set the default subscription. We can execute the below command for that.

Set-AzContext -SubscriptionName "Visual Studio Enterprise"

After executing the above command, I got the expected output, which is shown in the screenshot below.

How To Set Subscription In Azure PowerShell

Or, we can also use the SubscriptionID instead of Subscription name as per the below script.

Set-AzContext -SubscriptionId "1cdf4300-dee5-4518-9c9c-feaa72a5cbd1"

After executing the above command, I got the expected output, as shown in the screenshot below.

how to set azure subscription in powershell

You can also use the Select-AzSubscription to set the current subscription using the PowerShell command below.

Select-AzSubscription -SubscriptionId "1cdf4300-dee5-4518-9c9c-feaa72a5cbd1"

After executing the above command, I got the expected output, as shown in the screenshot below.

set subscription azure powershell

Video Tutorial

Conclusion

Setting subscription Azure using PowerShell is so easy using the Set-AzContext and Select-AzSubscription (old method). It is suggested to use the Set-AzContext PowerShell command as mentioned in this article.

You may also like following the articles below.

Azure Virtual Machine

DOWNLOAD FREE AZURE VIRTUAL MACHINE PDF

Download our free 25+ page Azure Virtual Machine guide and master cloud deployment today!