Skip to content

Commit a5d183c

Browse files
author
Jill Grant
authored
Merge pull request #277934 from davidsmatlak/ds-arg-move-managementgroups
Moves Management Groups include file for ARG sample
2 parents 9ff382a + b8ee300 commit a5d183c

File tree

2 files changed

+15
-29
lines changed

2 files changed

+15
-29
lines changed

includes/resource-graph/samples/bycat/management-groups.md renamed to articles/governance/includes/management-groups/management-groups.md

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
---
2-
author: davidsmatlak
3-
ms.service: resource-graph
2+
ms.service: governance
43
ms.topic: include
54
ms.date: 07/07/2022
6-
ms.author: davidsmatlak
7-
ms.custom: generated
5+
author: rthorn17
6+
ms.author: rithorn
87
---
98

109
### Count of subscriptions per management group
@@ -34,8 +33,6 @@ Search-AzGraph -Query "ResourceContainers | where type =~ 'microsoft.management/
3433

3534
# [Portal](#tab/azure-portal)
3635

37-
38-
3936
- Azure portal: <a href="https://portal.azure.com/#blade/HubsExtension/ArgQueryBlade/query/ResourceContainers%0a%7c%20where%20type%20%3d%7e%20%27microsoft.management%2fmanagementgroups%27%0a%7c%20project%20mgname%20%3d%20name%0a%7c%20join%20kind%3dleftouter%20(resourcecontainers%20%7c%20where%20type%3d%7e%20%27microsoft.resources%2fsubscriptions%27%0a%7c%20extend%20%20mgParent%20%3d%20properties.managementGroupAncestorsChain%20%7c%20project%20id%2c%20mgname%20%3d%20tostring(mgParent%5b0%5d.name))%20on%20mgname%0a%7c%20summarize%20count()%20by%20mgname" target="_blank">portal.azure.com</a>
4037
- Azure Government portal: <a href="https://portal.azure.us/#blade/HubsExtension/ArgQueryBlade/query/ResourceContainers%0a%7c%20where%20type%20%3d%7e%20%27microsoft.management%2fmanagementgroups%27%0a%7c%20project%20mgname%20%3d%20name%0a%7c%20join%20kind%3dleftouter%20(resourcecontainers%20%7c%20where%20type%3d%7e%20%27microsoft.resources%2fsubscriptions%27%0a%7c%20extend%20%20mgParent%20%3d%20properties.managementGroupAncestorsChain%20%7c%20project%20id%2c%20mgname%20%3d%20tostring(mgParent%5b0%5d.name))%20on%20mgname%0a%7c%20summarize%20count()%20by%20mgname" target="_blank">portal.azure.us</a>
4138
- Microsoft Azure operated by 21Vianet portal: <a href="https://portal.azure.cn/#blade/HubsExtension/ArgQueryBlade/query/ResourceContainers%0a%7c%20where%20type%20%3d%7e%20%27microsoft.management%2fmanagementgroups%27%0a%7c%20project%20mgname%20%3d%20name%0a%7c%20join%20kind%3dleftouter%20(resourcecontainers%20%7c%20where%20type%3d%7e%20%27microsoft.resources%2fsubscriptions%27%0a%7c%20extend%20%20mgParent%20%3d%20properties.managementGroupAncestorsChain%20%7c%20project%20id%2c%20mgname%20%3d%20tostring(mgParent%5b0%5d.name))%20on%20mgname%0a%7c%20summarize%20count()%20by%20mgname" target="_blank">portal.azure.cn</a>
@@ -44,7 +41,7 @@ Search-AzGraph -Query "ResourceContainers | where type =~ 'microsoft.management/
4441

4542
### List all management group ancestors for a specified management group
4643

47-
Provides the management group hierarchy details for the management group specified in the [query scope](../../../../articles/governance/resource-graph/concepts/query-language.md#query-scope). In this example, the management group is named **Application**.
44+
Provides the management group hierarchy details for the management group specified in the [query scope](../../resource-graph/concepts/query-language.md#query-scope). In this example, the management group is named **Application**.
4845

4946
```kusto
5047
ResourceContainers
@@ -68,8 +65,6 @@ Search-AzGraph -Query "ResourceContainers | where type =~ 'microsoft.management/
6865

6966
# [Portal](#tab/azure-portal)
7067

71-
72-
7368
- Azure portal: <a href="https://portal.azure.com/#blade/HubsExtension/ArgQueryBlade/query/ResourceContainers%0a%7c%20where%20type%20%3d%7e%20%27microsoft.management%2fmanagementgroups%27%0a%7c%20extend%20%20mgParent%20%3d%20properties.details.managementGroupAncestorsChain%0a%7c%20mv-expand%20with_itemindex%3dMGHierarchy%20mgParent%0a%7c%20project%20name%2c%20properties.displayName%2c%20mgParent%2c%20MGHierarchy%2c%20mgParent.name" target="_blank">portal.azure.com</a>
7469
- Azure Government portal: <a href="https://portal.azure.us/#blade/HubsExtension/ArgQueryBlade/query/ResourceContainers%0a%7c%20where%20type%20%3d%7e%20%27microsoft.management%2fmanagementgroups%27%0a%7c%20extend%20%20mgParent%20%3d%20properties.details.managementGroupAncestorsChain%0a%7c%20mv-expand%20with_itemindex%3dMGHierarchy%20mgParent%0a%7c%20project%20name%2c%20properties.displayName%2c%20mgParent%2c%20MGHierarchy%2c%20mgParent.name" target="_blank">portal.azure.us</a>
7570
- Azure operated by 21Vianet portal: <a href="https://portal.azure.cn/#blade/HubsExtension/ArgQueryBlade/query/ResourceContainers%0a%7c%20where%20type%20%3d%7e%20%27microsoft.management%2fmanagementgroups%27%0a%7c%20extend%20%20mgParent%20%3d%20properties.details.managementGroupAncestorsChain%0a%7c%20mv-expand%20with_itemindex%3dMGHierarchy%20mgParent%0a%7c%20project%20name%2c%20properties.displayName%2c%20mgParent%2c%20MGHierarchy%2c%20mgParent.name" target="_blank">portal.azure.cn</a>
@@ -78,7 +73,7 @@ Search-AzGraph -Query "ResourceContainers | where type =~ 'microsoft.management/
7873

7974
### List all management group ancestors for a specified subscription
8075

81-
Provides the management group hierarchy details for the subscription specified in the [query scope](../../../../articles/governance/resource-graph/concepts/query-language.md#query-scope). In this example, the subscription GUID is **11111111-1111-1111-1111-111111111111**.
76+
Provides the management group hierarchy details for the subscription specified in the [query scope](../../resource-graph/concepts/query-language.md#query-scope). In this example, the subscription GUID is `11111111-1111-1111-1111-111111111111`.
8277

8378
```kusto
8479
ResourceContainers
@@ -102,8 +97,6 @@ Search-AzGraph -Query "ResourceContainers | where type =~ 'microsoft.resources/s
10297

10398
# [Portal](#tab/azure-portal)
10499

105-
106-
107100
- Azure portal: <a href="https://portal.azure.com/#blade/HubsExtension/ArgQueryBlade/query/ResourceContainers%0a%7c%20where%20type%20%3d%7e%20%27microsoft.resources%2fsubscriptions%27%0a%7c%20extend%20%20mgParent%20%3d%20properties.managementGroupAncestorsChain%0a%7c%20mv-expand%20with_itemindex%3dMGHierarchy%20mgParent%0a%7c%20project%20subscriptionId%2c%20name%2c%20mgParent%2c%20MGHierarchy%2c%20mgParent.name" target="_blank">portal.azure.com</a>
108101
- Azure Government portal: <a href="https://portal.azure.us/#blade/HubsExtension/ArgQueryBlade/query/ResourceContainers%0a%7c%20where%20type%20%3d%7e%20%27microsoft.resources%2fsubscriptions%27%0a%7c%20extend%20%20mgParent%20%3d%20properties.managementGroupAncestorsChain%0a%7c%20mv-expand%20with_itemindex%3dMGHierarchy%20mgParent%0a%7c%20project%20subscriptionId%2c%20name%2c%20mgParent%2c%20MGHierarchy%2c%20mgParent.name" target="_blank">portal.azure.us</a>
109102
- Azure operated by 21Vianet portal: <a href="https://portal.azure.cn/#blade/HubsExtension/ArgQueryBlade/query/ResourceContainers%0a%7c%20where%20type%20%3d%7e%20%27microsoft.resources%2fsubscriptions%27%0a%7c%20extend%20%20mgParent%20%3d%20properties.managementGroupAncestorsChain%0a%7c%20mv-expand%20with_itemindex%3dMGHierarchy%20mgParent%0a%7c%20project%20subscriptionId%2c%20name%2c%20mgParent%2c%20MGHierarchy%2c%20mgParent.name" target="_blank">portal.azure.cn</a>
@@ -112,7 +105,7 @@ Search-AzGraph -Query "ResourceContainers | where type =~ 'microsoft.resources/s
112105

113106
### List all subscriptions under a specified management group
114107

115-
Provides the name and subscription ID of all subscriptions under the management group specified in the [query scope](../../../../articles/governance/resource-graph/concepts/query-language.md#query-scope). In this example, the management group is named **Application**.
108+
Provides the name and subscription ID of all subscriptions under the management group specified in the [query scope](../../resource-graph/concepts/query-language.md#query-scope). In this example, the management group is named **Application**.
116109

117110
```kusto
118111
ResourceContainers
@@ -134,8 +127,6 @@ Search-AzGraph -Query "ResourceContainers | where type =~ 'microsoft.resources/s
134127

135128
# [Portal](#tab/azure-portal)
136129

137-
138-
139130
- Azure portal: <a href="https://portal.azure.com/#blade/HubsExtension/ArgQueryBlade/query/ResourceContainers%0a%7c%20where%20type%20%3d%7e%20%27microsoft.resources%2fsubscriptions%27%0a%7c%20project%20subscriptionId%2c%20name" target="_blank">portal.azure.com</a>
140131
- Azure Government portal: <a href="https://portal.azure.us/#blade/HubsExtension/ArgQueryBlade/query/ResourceContainers%0a%7c%20where%20type%20%3d%7e%20%27microsoft.resources%2fsubscriptions%27%0a%7c%20project%20subscriptionId%2c%20name" target="_blank">portal.azure.us</a>
141132
- Azure operated by 21Vianet portal: <a href="https://portal.azure.cn/#blade/HubsExtension/ArgQueryBlade/query/ResourceContainers%0a%7c%20where%20type%20%3d%7e%20%27microsoft.resources%2fsubscriptions%27%0a%7c%20project%20subscriptionId%2c%20name" target="_blank">portal.azure.cn</a>
@@ -150,13 +141,13 @@ Returns secure score per management group.
150141
SecurityResources
151142
| where type == 'microsoft.security/securescores'
152143
| project subscriptionId,
153-
subscriptionTotal = iff(properties.score.max == 0, 0.00, round(tolong(properties.weight) * todouble(properties.score.current)/tolong(properties.score.max),2)),
154-
weight = tolong(iff(properties.weight == 0, 1, properties.weight))
144+
subscriptionTotal = iff(properties.score.max == 0, 0.00, round(tolong(properties.weight) * todouble(properties.score.current)/tolong(properties.score.max),2)),
145+
weight = tolong(iff(properties.weight == 0, 1, properties.weight))
155146
| join kind=leftouter (
156-
ResourceContainers
157-
| where type == 'microsoft.resources/subscriptions' and properties.state == 'Enabled'
158-
| project subscriptionId, mgChain=properties.managementGroupAncestorsChain )
159-
on subscriptionId
147+
ResourceContainers
148+
| where type == 'microsoft.resources/subscriptions' and properties.state == 'Enabled'
149+
| project subscriptionId, mgChain=properties.managementGroupAncestorsChain )
150+
on subscriptionId
160151
| mv-expand mg=mgChain
161152
| summarize sumSubs = sum(subscriptionTotal), sumWeight = sum(weight), resultsNum = count() by tostring(mg.displayName), mgId = tostring(mg.name)
162153
| extend secureScore = iff(tolong(resultsNum) == 0, 404.00, round(sumSubs/sumWeight*100,2))
@@ -178,8 +169,6 @@ Search-AzGraph -Query "SecurityResources | where type == 'microsoft.security/sec
178169

179170
# [Portal](#tab/azure-portal)
180171

181-
182-
183172
- Azure portal: <a href="https://portal.azure.com/#blade/HubsExtension/ArgQueryBlade/query/SecurityResources%0a%7c%20where%20type%20%3d%3d%20%27microsoft.security%2fsecurescores%27%0a%7c%20project%20subscriptionId%2c%0a%09subscriptionTotal%20%3d%20iff(properties.score.max%20%3d%3d%200%2c%200.00%2c%20round(tolong(properties.weight)%20*%20todouble(properties.score.current)%2ftolong(properties.score.max)%2c2))%2c%0a%09weight%20%3d%20tolong(iff(properties.weight%20%3d%3d%200%2c%201%2c%20properties.weight))%0a%7c%20join%20kind%3dleftouter%20(%0a%09ResourceContainers%0a%09%7c%20where%20type%20%3d%3d%20%27microsoft.resources%2fsubscriptions%27%20and%20properties.state%20%3d%3d%20%27Enabled%27%0a%09%7c%20project%20subscriptionId%2c%20mgChain%3dproperties.managementGroupAncestorsChain%20)%0a%09on%20subscriptionId%0a%7c%20mv-expand%20mg%3dmgChain%0a%7c%20summarize%20sumSubs%20%3d%20sum(subscriptionTotal)%2c%20sumWeight%20%3d%20sum(weight)%2c%20resultsNum%20%3d%20count()%20by%20tostring(mg.displayName)%2c%20mgId%20%3d%20tostring(mg.name)%0a%7c%20extend%20secureScore%20%3d%20iff(tolong(resultsNum)%20%3d%3d%200%2c%20404.00%2c%20round(sumSubs%2fsumWeight*100%2c2))%0a%7c%20project%20mgName%3dmg_displayName%2c%20mgId%2c%20sumSubs%2c%20sumWeight%2c%20resultsNum%2c%20secureScore%0a%7c%20order%20by%20mgName%20asc" target="_blank">portal.azure.com</a>
184173
- Azure Government portal: <a href="https://portal.azure.us/#blade/HubsExtension/ArgQueryBlade/query/SecurityResources%0a%7c%20where%20type%20%3d%3d%20%27microsoft.security%2fsecurescores%27%0a%7c%20project%20subscriptionId%2c%0a%09subscriptionTotal%20%3d%20iff(properties.score.max%20%3d%3d%200%2c%200.00%2c%20round(tolong(properties.weight)%20*%20todouble(properties.score.current)%2ftolong(properties.score.max)%2c2))%2c%0a%09weight%20%3d%20tolong(iff(properties.weight%20%3d%3d%200%2c%201%2c%20properties.weight))%0a%7c%20join%20kind%3dleftouter%20(%0a%09ResourceContainers%0a%09%7c%20where%20type%20%3d%3d%20%27microsoft.resources%2fsubscriptions%27%20and%20properties.state%20%3d%3d%20%27Enabled%27%0a%09%7c%20project%20subscriptionId%2c%20mgChain%3dproperties.managementGroupAncestorsChain%20)%0a%09on%20subscriptionId%0a%7c%20mv-expand%20mg%3dmgChain%0a%7c%20summarize%20sumSubs%20%3d%20sum(subscriptionTotal)%2c%20sumWeight%20%3d%20sum(weight)%2c%20resultsNum%20%3d%20count()%20by%20tostring(mg.displayName)%2c%20mgId%20%3d%20tostring(mg.name)%0a%7c%20extend%20secureScore%20%3d%20iff(tolong(resultsNum)%20%3d%3d%200%2c%20404.00%2c%20round(sumSubs%2fsumWeight*100%2c2))%0a%7c%20project%20mgName%3dmg_displayName%2c%20mgId%2c%20sumSubs%2c%20sumWeight%2c%20resultsNum%2c%20secureScore%0a%7c%20order%20by%20mgName%20asc" target="_blank">portal.azure.us</a>
185174
- Azure operated by 21Vianet portal: <a href="https://portal.azure.cn/#blade/HubsExtension/ArgQueryBlade/query/SecurityResources%0a%7c%20where%20type%20%3d%3d%20%27microsoft.security%2fsecurescores%27%0a%7c%20project%20subscriptionId%2c%0a%09subscriptionTotal%20%3d%20iff(properties.score.max%20%3d%3d%200%2c%200.00%2c%20round(tolong(properties.weight)%20*%20todouble(properties.score.current)%2ftolong(properties.score.max)%2c2))%2c%0a%09weight%20%3d%20tolong(iff(properties.weight%20%3d%3d%200%2c%201%2c%20properties.weight))%0a%7c%20join%20kind%3dleftouter%20(%0a%09ResourceContainers%0a%09%7c%20where%20type%20%3d%3d%20%27microsoft.resources%2fsubscriptions%27%20and%20properties.state%20%3d%3d%20%27Enabled%27%0a%09%7c%20project%20subscriptionId%2c%20mgChain%3dproperties.managementGroupAncestorsChain%20)%0a%09on%20subscriptionId%0a%7c%20mv-expand%20mg%3dmgChain%0a%7c%20summarize%20sumSubs%20%3d%20sum(subscriptionTotal)%2c%20sumWeight%20%3d%20sum(weight)%2c%20resultsNum%20%3d%20count()%20by%20tostring(mg.displayName)%2c%20mgId%20%3d%20tostring(mg.name)%0a%7c%20extend%20secureScore%20%3d%20iff(tolong(resultsNum)%20%3d%3d%200%2c%20404.00%2c%20round(sumSubs%2fsumWeight*100%2c2))%0a%7c%20project%20mgName%3dmg_displayName%2c%20mgId%2c%20sumSubs%2c%20sumWeight%2c%20resultsNum%2c%20secureScore%0a%7c%20order%20by%20mgName%20asc" target="_blank">portal.azure.cn</a>

articles/governance/management-groups/resource-graph-samples.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,17 @@ ms.date: 07/07/2022
55
ms.topic: sample
66
ms.custom: subject-resourcegraph-sample, devx-track-azurepowershell, devx-track-azurecli
77
---
8+
89
# Azure Resource Graph sample queries for management groups
910

1011
This page is a collection of [Azure Resource Graph](../resource-graph/overview.md) sample queries
11-
for management groups. For a complete list of Azure Resource Graph samples, see
12-
[Resource Graph samples by Category](../resource-graph/samples/samples-by-category.md) and
13-
[Resource Graph samples by Table](../resource-graph/samples/samples-by-table.md).
12+
for management groups.
1413

1514
## Sample queries
1615

17-
[!INCLUDE [azure-resource-graph-samples-cat-mgs](../../../includes/resource-graph/samples/bycat/management-groups.md)]
16+
[!INCLUDE [azure-resource-graph-samples-cat-mgs](../includes/management-groups/management-groups.md)]
1817

1918
## Next steps
2019

2120
- Learn more about the [query language](../resource-graph/concepts/query-language.md).
2221
- Learn more about how to [explore resources](../resource-graph/concepts/explore-resources.md).
23-
- See samples of [Starter language queries](../resource-graph/samples/starter.md).
24-
- See samples of [Advanced language queries](../resource-graph/samples/advanced.md).

0 commit comments

Comments
 (0)