Jaa


What is my current Azure Resource Manager subscription?

Just a brief note this time. Like many who learned Azure in the old days of Azure Service Manager (a.k.a. classic IaaS), I have number of things to unlearn while adjusting to Azure Resource Manager (ARM). Today I struggled for at least thirty minutes trying to find out the default subscription in an ARM Powershell session. In the old ways it was like this; you log on, and you list the subscriptions and filter the default one:

[powershell]
Add-AzureAccount
Get-AzureSubscription | Where-Object isdefault -eq $true
[/powershell]

But there is no equivalent in ARM! Sure, there is Get-AzureRMSubscription, but it has no properties indicating if a subscription is the default one or not. It turns out to be very simple. You just ask for it using Get-AzureRMContext:

[powershell]
Add-AzureRmAccount
Get-AzureRmContext
[/powershell]

And to finish this off, you select a different default subscription like this:

[powershell]
Get-AzureRmSubscription |
Where-Object subscriptionname -eq "contoso" |
Select-AzureRmSubscription
[/powershell]