Get-AzureRmResourceGroup not returning resources from current subscription
If I run
Get-AzureSubscription -Current
I get:
SubscriptionId : a*<guid>
SubscriptionName : Development
Environment : AzureCloud
DefaultAccount : t*<guid>
IsDefault : True
IsCurrent : True
TenantId : 4*<guid>
Then I run:
Get-AzureRmResourceGroup
And neither of the two resources returned are in that subscription, of which there should many, according to the portal:
ResourceGroupName : Default-SQL-NorthCentralUS
Location : northcentralus
ProvisioningState : Succeeded
Tags :
ResourceId : /subscriptions/0*<guid>*e/resourceGroups/Default-SQL-NorthCentralUS
ResourceGroupName : Default-Web-NorthCentralUS
Location : northcentralus
ProvisioningState : Succeeded
Tags :
ResourceId : /subscriptions/0*<guid>*e/resourceGroups/Default-Web-NorthCentralUS
These are coming from another subscription I have, but as you can see, isn't the current one.
Why isn't Get-AzureRmResourceGroup
getting the resource groups in the current subscription, and now do I fix this?
My Azure module is version 0.9.11 and AzureRM is version 1.0.1.
I also don't have access to Switch-AzureMode
or Get-AzureResourceGroup
Solution 1:
I had to use
Select-AzureRmSubscription -SubscriptionId a*<guid>
Thanks to Michael Rodger for providing the answer.
Solution 2:
You need to setup the context using below command if you have multiple subscriptions:
Set-AzureRmContext -SubscriptionName "Name"