Set Default Subscription Using Azure Service Management Cmdlets In Azure Powershell

We can use Azure PowerShell, using Azure Resource Manager (ARM) and Azure Service Management (ASM) module to manage Azure resources. Here, we will see, how to set the default subscription, using ASM module’s cmdlets.

To complete this tutorial, you'll need the following,

  • An active Azure account. (If you don't have an account, you can create a free trial account in couple of minutes. For details, see Azure Free Trial.)
  • Installing and configuring of PowerShell for Azure, as shown in this article: Configuring Powershell For Azure.

Follow the steps, given below, to set the default subscription in Azure PowerShell,  using ASM module cmdlets:

  1. Run Azure PowerShell console or PowerShell Integrated Scripting Environment (ISE) as an administrator. I am using ISE, as shown in the image, given below. I have pinned Azure PowerShell to the taskbar. It might be different in your case, if running PowerShell ISE from the start or the desktop shortcut or by searching in start or also depends on which OS you are using.

    ISE

  2. The step 1 action will open the Windows PowerShell ISE in an administrator mode, as shown in the image, given below:

    Windows PowerShell ISE

  3. Enter Add-AzureAccount and hit enter, as shown in the image, given below:

    Add-AzureAccount

  4. The above action will open Microsoft sign in page, as shown in the image, given below and enter the user ID.

    sign in

  5. Press tab after entering the user ID. If your ID is associated with work the and personal account type, you will get another Window, as shown in the image, given below:

    account type

  6. Select correct account type. This will take you to enter the password, as shown in the image, given below:

    account type

  7. Enter the password and click Sign in button. This action authenticates with Azure and if success returns with the account details, as shown in the image, given below: 

     Sign n

  8. Type Get-AzureSubscription cmdlets to get the list of the available subscriptions, as shown in the image, given below:

    available subscriptions

    As we can observe, my first subscription is the default subscription. I want to set Azure Pass, as the default subscription in PowerShell to work with.

  9. Type Select-AzureSubscription and provide SubscriptionID parameter value, as shown in the image, given below and hit enter.

    AzureSubscription

  10. Now, check with Get-AzureSubscription cmdlets, as shown in the image, given below. Azure Pass is the default subscription.

    subscription

Here, we have seen, how to set Azure subscription as a default subscription in Azure PowerShell. l am using Azure Service Management module’s cmdlets.


Similar Articles