Reputation: 1490
How can I get resource group name, subscription name and id for all the resource groups?
I can get all resourcegroups with
Resources| distinct resourceGroup
But if I add "id" in there I get same resourcegroup multiple times.
Resources | distinct resourceGroup, id
Upvotes: 0
Views: 994
Reputation: 5506
I understand, you want to pull the subscription Name, resource group name, id using the resource graph explorer. you can use the below KQL query.
resourcecontainers
| where type == "microsoft.resources/subscriptions"
| join ( resourcecontainers | where type == "microsoft.resources/subscriptions/resourcegroups") on subscriptionId
| distinct name,name1,id1
| project SubscriptionName=name,resourceGroupName=name1, resourceGroupId=id1
Upvotes: 1