Kamsiinov
Kamsiinov

Reputation: 1490

Kusto get resourcegroups and subscription information

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

Answers (1)

VenkateshDodda
VenkateshDodda

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

Related Questions