Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Change the Default Azure RM subscription

ASM had the ability to change the default subscription with the -Default (and now deprecated) parameter

Select-AzureSubscription -Default 

but the ARM version

Select-AzureRMSubscription  

does not have the -Default parameter.

How can I change the default ARM subscription? It is very annoying that my default is a subscription that I never use.

Edit for clarification: When I say change default subscription I mean the default subscription that you are connected to with each new PowerShell session.

like image 621
Mikee Avatar asked Dec 05 '16 16:12

Mikee


People also ask

How do I change my default Azure subscription?

You can change the default settings of the Azure portal to meet your own preferences. Most settings are available from the Settings menu in the top right section of global page header.

How do I change the default subscription for Azure PowerShell?

To change the azure subscription using PowerShell, we can use the Select-AZSubscription command. When you use this command, you can use either the subscription ID, Subscription Name, or the Tenant ID.

How do I change a PowerShell subscription?

Change the active subscription In order to change subscriptions, you use the Set-AzContext cmdlet to change the current context. You can use the Get-AzSubscription cmdlet to retrieve a list of your Azure subscriptions.

What is set AzureRmContext?

The Set-AzureRmContext cmdlet sets authentication information for cmdlets that you run in the current session. The context includes tenant, subscription, and environment information.


1 Answers

Step 1: Get-AzureRmSubscription

It will List all your subscriptions.

Step 2: Select-AzureRmSubscription -SubscriptionId xxxxx-xxxxx-xxxxxx-xxxx

The SubscriptionID can be found in the output of the Get-AzureRmSubscription. You can also use the SubscriptionName.

Step 3: (Get-AzureRmContext).Subscription

Confirm that you have selected the right subscription.

like image 180
Clavin Fernandes Avatar answered Sep 19 '22 10:09

Clavin Fernandes