List resource groups in a particular subscription
Sunday 30, September 2018 | Post link
As an Azure developer you may be having access to more than one subscription. To get a list of subscriptions you can use Get-AzureRMSubscription cmdlet.
PS C:\WINDOWS\system32> Get-AzureRMSubscription Name : MySub 1 Dev - USW - 90 Id : 03a2aaea-0861-777c-9a66-5dfffaa779ae TenantId : 11111111-2222-3333-4444-ca318e612345 State : Enabled Name : MySub 2 Prod Id : 12345678-262b-44be-b198-f65420123456 TenantId : 11111111-2222-3333-4444-ca318e612345 State : Enabled
Now that you have the list of subscriptions, suppose you want to work on the one named 'MySub 2 Prod' you'll need to make it the active one using the Select-AzureRMSubscription cmdlet.
PS C:\WINDOWS\system32> Select-AzureRMSubscription -SubscriptionID 12345678-262b-44be-b198-f65420123456 Name : MySub 2 Prod (12345678-262b-44be-b198-f65420123456) - siddharthsemail@email.com Account : siddharthsemail@email.com SubscriptionName : MySub 2 Prod TenantId : 11111111-2222-3333-4444-ca318e612345 Environment : AzureCloud
Now that the subscription has been selected, running Get-AzureRMResourceGroup will return only the resource groups in the selected subscription.
PS C:\WINDOWS\system32> Get-AzureRMResourceGroup | Select-Object { $_.ResourceGroupName } $_.ResourceGroupName ---------------------- AzureTraining AzureTesting AzureDevelopment
Categories:
Azure (2)
Tags:
Azure(2)
PowerShell(2)
Comments