Reputation: 12228
In Azure Classic / Service Management, Get-AzureSubscription would give a list of subscriptions in the Tenant with an indicator of which was current.
There was also a Get-AzureSubscription -Current
flag that would give you just the current subscription.
Is there a way to find the current subscription in AzureRM.Profile?
Upvotes: 26
Views: 27560
Reputation: 43
Get-AzureRmContext
and Get-AzContext
both are valid but Get-AzContext
is latest way to do it
You might have seen or used Azure PowerShell commands that used an -AzureRM format. In December 2018 Microsoft released for general availability the AzureRM module replacement with the Az module. This new module has several features, notably a shortened cmdlet noun prefix of -Az, which replaces AzureRM. The Az module ships with backwards compatibility for the AzureRM module, so the -AzureRM cmdlet format will work.
Upvotes: 1
Reputation: 461
You can also use Get-AzureRmSubscription
$sub = Get-AzureRmSubscription
$sub.SubscriptionId
This will give you the SubscriptionId
Upvotes: 1
Reputation: 12452
Get-AzureRmContext
gives you info about the selected subscription, default storage account, etc.
(Get-AzureRmContext).Subscription
gives you the current subscription.
Upvotes: 58