Skip to content

Commit 1e89029

Browse files
authored
Merge pull request #301799 from kenieva/patch-5
Service Groups ARG sample queries
2 parents 8dec3f1 + ca27493 commit 1e89029

File tree

4 files changed

+121
-0
lines changed

4 files changed

+121
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
author: kenieva
3+
ms.service: resource-graph
4+
ms.topic: include
5+
ms.date: 06/20/2025
6+
ms.author: kenieva
7+
---
8+
9+
### List of all Service Groups
10+
11+
Outputs a list of Service Groups.
12+
13+
```kusto
14+
resourcecontainers
15+
| where type == "microsoft.management/servicegroups"
16+
```
17+
18+
# [Azure CLI](#tab/azure-cli)
19+
20+
```azurecli-interactive
21+
az graph query -q "resourcecontainers | where type == 'microsoft.management/servicegroups'"
22+
```
23+
24+
# [Azure PowerShell](#tab/azure-powershell)
25+
26+
```azurepowershell-interactive
27+
Search-AzGraph -Query "resourcecontainers | where type == 'microsoft.management/servicegroups'" -UseTenantScope
28+
```
29+
30+
# [Portal](#tab/azure-portal)
31+
32+
- Azure portal: <a>[portal.azure.com](https://portal.azure.com/#view/HubsExtension/ArgQueryBlade/query/resourcecontainers%0A%7C%20where%20type%20%3D%3D%20%22microsoft.management%2Fservicegroups%22)</a>
33+
34+
---
35+
36+
### List of all members for a particular Service Group
37+
38+
Outputs a list of resource IDs that are members for a particular Service Groups. In this example, the service group ID is '123'.
39+
40+
```kusto
41+
relationshipresources
42+
    | where type == "microsoft.relationships/servicegroupmember"
43+
| where properties.TargetId == '/providers/Microsoft.Management/serviceGroups/123'
44+
| project properties.SourceId
45+
```
46+
47+
# [Azure CLI](#tab/azure-cli)
48+
49+
```azurecli-interactive
50+
az graph query -q "relationshipresources| where type == 'microsoft.relationships/servicegroupmember'| where properties.TargetId == '/providers/Microsoft.Management/serviceGroups/123' | project properties.SourceId"
51+
```
52+
53+
# [Azure PowerShell](#tab/azure-powershell)
54+
55+
```azurepowershell-interactive
56+
Search-AzGraph -Query "relationshipresources| where type == 'microsoft.relationships/servicegroupmember'| where properties.TargetId == '/providers/Microsoft.Management/serviceGroups/123' | project properties.SourceId" -UseTenantScope
57+
```
58+
59+
# [Portal](#tab/azure-portal)
60+
61+
- Azure portal: <a>[portal.azure.com](https://portal.azure.com/#view/HubsExtension/ArgQueryBlade/query/relationshipresources%7C%20where%20type%20%3D%3D%20'microsoft.relationships%2Fservicegroupmember'%7C%20where%20properties.TargetId%20%3D%3D%20'%2Fproviders%2FMicrosoft.Management%2FserviceGroups%2F123'%20%7C%20project%20properties.SourceId)</a>
62+
63+
---
64+
65+
### Count of Members for all Service Groups
66+
67+
Provides a count of service group members for a particular service group. In this example, the service group ID is '123'.
68+
69+
```kusto
70+
relationshipresources
71+
    | where type == "microsoft.relationships/servicegroupmember"
72+
| where properties.TargetId == '/providers/Microsoft.Management/serviceGroups/123'
73+
| count
74+
```
75+
76+
# [Azure CLI](#tab/azure-cli)
77+
78+
```azurecli-interactive
79+
az graph query -q "relationshipresources| where type == 'microsoft.relationships/servicegroupmember'| where properties.TargetId == '/providers/Microsoft.Management/serviceGroups/123' | count"
80+
```
81+
82+
# [Azure PowerShell](#tab/azure-powershell)
83+
84+
```azurepowershell-interactive
85+
Search-AzGraph -Query "relationshipresources| where type == 'microsoft.relationships/servicegroupmember'| where properties.TargetId == '/providers/Microsoft.Management/serviceGroups/123' | count" -UseTenantScope
86+
```
87+
88+
# [Portal](#tab/azure-portal)
89+
90+
- Azure portal: <a>[portal.azure.com](https://portal.azure.com/#view/HubsExtension/ArgQueryBlade/query/relationshipresources%7C%20where%20type%20%3D%3D%20'microsoft.relationships%2Fservicegroupmember'%7C%20where%20properties.TargetId%20%3D%3D%20'%2Fproviders%2FMicrosoft.Management%2FserviceGroups%2F123'%20%7C%20count)</a>
91+
92+
---

articles/governance/resource-graph/samples/samples-by-category.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ Otherwise, use <kbd>Ctrl</kbd>-<kbd>F</kbd> to use your browser's search feature
125125

126126
[!INCLUDE [azure-resource-graph-samples-cat-resource-health](../includes/samples-by-category/resource-health.md)]
127127

128+
## Service Groups
129+
130+
[!INCLUDE [azure-resource-graph-cat-service-groups](../includes/samples-by-category/service-groups.md)]
131+
128132
## Tags
129133

130134
[!INCLUDE [azure-resource-graph-samples-cat-tags](../includes/samples-by-category/tags.md)]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: Azure Resource Graph sample queries for Service Groups
3+
description: Sample Azure Resource Graph queries for servicegroups showing use of resource type and tables to access service group and membership details.
4+
ms.date: 06/27/2025
5+
ms.topic: sample
6+
ms.custom: subject-resourcegraph-sample, devx-track-azurepowershell, devx-track-azurecli
7+
---
8+
9+
# Azure Resource Graph sample queries for Service Groups
10+
11+
This page is a collection of [Azure Resource Graph](../resource-graph/overview.md) sample queries
12+
for service groups.
13+
14+
## Sample queries
15+
16+
[!INCLUDE [azure-resource-graph-samples-service-groups](../resource-graph/includes/samples-by-category/service-groups.md)]
17+
18+
## Next steps
19+
20+
- Learn more about the [query language](../resource-graph/concepts/query-language.md).
21+
- Learn more about how to [explore resources](../resource-graph/concepts/explore-resources.md).

articles/governance/service-groups/toc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
href: create-service-group-member-rest-api.md
1313
- name: How to use Service Groups to manage resources
1414
href: manage-service-groups.md
15+
- name: Samples
16+
items:
17+
- name: Azure Resource Graph queries
18+
href: ./resource-graph-samples.md
1519
- name: Reference
1620
items:
1721
- name: Resource Manager templates

0 commit comments

Comments
 (0)