Skip to content
Related Articles
Open in App
Not now

Related Articles

Microsoft Azure – Get Management Groups Information Using KQL

Improve Article
Save Article
  • Last Updated : 15 Nov, 2022
Improve Article
Save Article

In this article, you will get to know how you can get information about azure management groups using the azure resource graph queries in a faster and simple way. Run all the below following KQL queries in Azure Resource Graph Explorer from Azure Portal to get the results. You can also export the data by clicking on Download as CSV from the Results section. The user should have read access to the management group subscriptions to fetch the data.

Use the following KQL query for the information on management group details.

Query:

ResourceContainers
| where type =~ 'microsoft.management/managementgroups'

Output:

kql query

 

Use the following KQL query to get the count of Management Groups in Azure Active Directory.

Query:

ResourceContainers
| where type =~ 'microsoft.management/managementgroups'
| count

Output:

kql query

 

Use the following KQL query to get the Azure Management Group information with the Management Group Name and its properties.

Query:

ResourceContainers
| where type =~ 'microsoft.management/managementgroups'
| project name,properties

Output:

name prop

 

Use the below KQL query to get the count of azure subscriptions under each management group.

Query:

ResourceContainers
| where type =~ 'microsoft.management/managementgroups'
| project mgname = name
| join kind=leftouter (resourcecontainers 
| where type=~ 'microsoft.resources/subscriptions'
| extend  mgParent = properties.managementGroupAncestorsChain 
| project id, mgname = tostring(mgParent[0].name)) on mgname
| summarize count() by mgname

Output:

get the count of azure subscription

 

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!