You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/governance/resource-graph/first-query-azurecli.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "Quickstart: Run Resource Graph query using Azure CLI"
3
3
description: In this quickstart, you run a Resource Graph query using Azure CLI and the resource-graph extension.
4
-
ms.date: 06/26/2024
4
+
ms.date: 06/27/2024
5
5
ms.topic: quickstart
6
6
ms.custom: devx-track-azurecli
7
7
---
@@ -16,18 +16,6 @@ This quickstart describes how to run an Azure Resource Graph query using the Azu
16
16
-[Azure CLI](/cli/azure/install-azure-cli) must be version 2.22.0 or higher for the Resource Graph extension.
17
17
- A Bash shell environment where you can run Azure CLI commands. For example, Git Bash in a [Visual Studio Code](https://code.visualstudio.com/) terminal session.
18
18
19
-
## Connect to Azure
20
-
21
-
From a Visual Studio Code terminal session, connect to Azure. If you have more than one subscription, run the commands to set context to your subscription. Replace `<subscriptionID>` with your Azure subscription ID.
22
-
23
-
```azurecli
24
-
az login
25
-
26
-
# Run these commands if you have multiple subscriptions
27
-
az account list --output table
28
-
az account set --subscription <subscriptionID>
29
-
```
30
-
31
19
## Install the extension
32
20
33
21
To enable Azure CLI to query resources using Azure Resource Graph, the Resource Graph extension must be installed. The first time you run a query with `az graph` a prompt is displayed to install the extension. Otherwise, use the following steps to do a manual installation.
@@ -58,6 +46,18 @@ To enable Azure CLI to query resources using Azure Resource Graph, the Resource
58
46
59
47
For more information about Azure CLI extensions, go to [Use and manage extensions with the Azure CLI](/cli/azure/azure-cli-extensions-overview).
60
48
49
+
## Connect to Azure
50
+
51
+
From a Visual Studio Code terminal session, connect to Azure. If you have more than one subscription, run the commands to set context to your subscription. Replace `<subscriptionID>` with your Azure subscription ID.
52
+
53
+
```azurecli
54
+
az login
55
+
56
+
# Run these commands if you have multiple subscriptions
57
+
az account list --output table
58
+
az account set --subscription <subscriptionID>
59
+
```
60
+
61
61
## Run a query
62
62
63
63
After the Azure CLI extension is added to your environment, you can run a tenant-based query. The query in this example returns five Azure resources with the `name` and `type` of each resource. To query by [management group](../management-groups/overview.md) or subscription, use the `--management-groups` or `--subscriptions` arguments.
@@ -102,7 +102,7 @@ az logout
102
102
103
103
## Next steps
104
104
105
-
In this quickstart, you ran Azure Resource Graph queries using the extension for Azure CLI. To learn more, go to the query language details article.
105
+
In this quickstart, you ran Azure Resource Graph queries using the extension for Azure CLI. To learn more about the Resource Graph language, continue to the query language details page.
106
106
107
107
> [!div class="nextstepaction"]
108
108
> [Understanding the Azure Resource Graph query language](./concepts/query-language.md)
Copy file name to clipboardExpand all lines: articles/governance/resource-graph/shared-query-azure-cli.md
+23-17Lines changed: 23 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "Quickstart: Create Resource Graph shared query using Azure CLI"
3
3
description: In this quickstart, you create an Azure Resource Graph shared query using Azure CLI and the resource-graph extension.
4
-
ms.date: 06/26/2024
4
+
ms.date: 06/27/2024
5
5
ms.topic: quickstart
6
6
ms.custom: devx-track-azurecli
7
7
---
@@ -18,18 +18,6 @@ A shared query can be run from Azure CLI with the _experimental_ feature's comma
18
18
-[Azure CLI](/cli/azure/install-azure-cli) must be version 2.22.0 or higher for the Resource Graph extension.
19
19
- A Bash shell environment where you can run Azure CLI commands. For example, Git Bash in a [Visual Studio Code](https://code.visualstudio.com/) terminal session.
20
20
21
-
## Connect to Azure
22
-
23
-
From a Visual Studio Code terminal session, connect to Azure. If you have more than one subscription, run the commands to set context to your subscription. Replace `<subscriptionID>` with your Azure subscription ID.
24
-
25
-
```azurecli
26
-
az login
27
-
28
-
# Run these commands if you have multiple subscriptions
29
-
az account list --output table
30
-
az account set --subscription <subscriptionID>
31
-
```
32
-
33
21
## Install the extension
34
22
35
23
To enable Azure CLI to query resources using Azure Resource Graph, the Resource Graph extension must be installed. The first time you run a query with `az graph` a prompt is displayed to install the extension. Otherwise, use the following steps to do a manual installation.
@@ -60,6 +48,18 @@ To enable Azure CLI to query resources using Azure Resource Graph, the Resource
60
48
61
49
For more information about Azure CLI extensions, go to [Use and manage extensions with the Azure CLI](/cli/azure/azure-cli-extensions-overview).
62
50
51
+
## Connect to Azure
52
+
53
+
From a Visual Studio Code terminal session, connect to Azure. If you have more than one subscription, run the commands to set context to your subscription. Replace `<subscriptionID>` with your Azure subscription ID.
54
+
55
+
```azurecli
56
+
az login
57
+
58
+
# Run these commands if you have multiple subscriptions
59
+
az account list --output table
60
+
az account set --subscription <subscriptionID>
61
+
```
62
+
63
63
## Create a shared query
64
64
65
65
Create a resource group and a shared that summarizes the count of all resources grouped by location.
@@ -126,16 +126,24 @@ You can verify the shared query works using Azure Resource Graph Explorer. To ch
126
126
1. Change **Type** to _Shared queries_.
127
127
1. Select the query _Count VMs by OS_.
128
128
1. Select **Run query** and the view output in the **Results** tab.
129
+
1. Select **Charts** and then select **Map** to view the location map.
129
130
130
131
You can also run the query from your resource group.
131
132
132
133
1. In Azure, go to the resource group, _demoSharedQuery_.
133
134
1. From the **Overview** tab, select the query _Count VMs by OS_.
134
135
1. Select the **Results** tab.
136
+
1. Select **Charts** and then select **Map** to view the location map.
135
137
136
138
## Clean up resources
137
139
138
-
To remove the resource group and shared query:
140
+
To remove the shared query:
141
+
142
+
```azurecli
143
+
az graph shared-query delete --name "Summarize resources by location" --resource-group demoSharedQuery
144
+
```
145
+
146
+
When a resource group is deleted, the resource group and all its resources are deleted. To remove the resource group:
139
147
140
148
```azurecli
141
149
az group delete --name demoSharedQuery
@@ -155,9 +163,7 @@ az logout
155
163
156
164
## Next steps
157
165
158
-
In this quickstart, you added the Resource Graph extension to your Azure CLI environment and
159
-
created a shared query. To learn more about the Resource Graph language, continue to the query
160
-
language details page.
166
+
In this quickstart, you added the Resource Graph extension to your Azure CLI environment and created a shared query. To learn more about the Resource Graph language, continue to the query language details page.
161
167
162
168
> [!div class="nextstepaction"]
163
169
> [Understanding the Azure Resource Graph query language](./concepts/query-language.md)
@@ -89,13 +89,13 @@ Use Azure CLI or Azure PowerShell to list the deployed resources in the resource
89
89
# [Azure CLI](#tab/azure-cli)
90
90
91
91
```azurecli
92
-
az resource list --resource-group exampleRG
92
+
az resource list --resource-group demoSharedQuery
93
93
```
94
94
95
95
# [Azure PowerShell](#tab/azure-powershell)
96
96
97
97
```azurepowershell
98
-
Get-AzResource -ResourceGroupName exampleRG
98
+
Get-AzResource -ResourceGroupName demoSharedQuery
99
99
```
100
100
101
101
---
@@ -116,18 +116,18 @@ You can verify the shared query works using Azure Resource Graph Explorer. To ch
116
116
117
117
You can also run the query from your resource group.
118
118
119
-
1. In Azure, go to the resource group, _exampleRG_.
119
+
1. In Azure, go to the resource group, _demoSharedQuery_.
120
120
1. From the **Overview** tab, select the query _Count VMs by OS_.
121
121
1. Select the **Results** tab.
122
122
123
123
## Clean up resources
124
124
125
-
When you no longer need the resource that you created, delete the resource group using Azure CLI or Azure PowerShell. And if you signed into Azure portal to run the query, be sure to sign out.
125
+
When you no longer need the resource that you created, delete the resource group using Azure CLI or Azure PowerShell. When a resource group is deleted, the resource group and all its resources are deleted. And if you signed into Azure portal to run the query, be sure to sign out.
126
126
127
127
# [Azure CLI](#tab/azure-cli)
128
128
129
129
```azurecli
130
-
az group delete --name exampleRG
130
+
az group delete --name demoSharedQuery
131
131
```
132
132
133
133
To sign out of your Azure CLI session:
@@ -139,7 +139,7 @@ az logout
139
139
# [Azure PowerShell](#tab/azure-powershell)
140
140
141
141
```azurepowershell
142
-
Remove-AzResourceGroup -Name exampleRG
142
+
Remove-AzResourceGroup -Name demoSharedQuery
143
143
```
144
144
145
145
To sign out of your Azure PowerShell session:
@@ -152,9 +152,7 @@ Disconnect-AzAccount
152
152
153
153
## Next steps
154
154
155
-
In this quickstart, you created a Resource Graph shared query using Bicep.
156
-
157
-
To learn more about shared queries, continue to the tutorial for:
155
+
In this quickstart, you created a Resource Graph shared query using Bicep. To learn more about the Resource Graph language, continue to the query language details page.
158
156
159
157
> [!div class="nextstepaction"]
160
-
> [Tutorial: Create and share an Azure Resource Graph query in the Azure portal](./tutorials/create-share-query.md)
158
+
> [Understanding the Azure Resource Graph query language](./concepts/query-language.md)
Copy file name to clipboardExpand all lines: articles/governance/resource-graph/shared-query-template.md
+3-5Lines changed: 3 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
---
2
-
title: 'Quickstart: Create Resource Graph shared query using ARM template'
2
+
title: "Quickstart: Create Resource Graph shared query using ARM template"
3
3
description: In this quickstart, you use an Azure Resource Manager template (ARM template) to create a Resource Graph shared query that counts virtual machines by OS.
4
4
ms.date: 06/26/2024
5
5
ms.topic: quickstart
@@ -91,9 +91,7 @@ To remove the shared query created, follow these steps:
91
91
92
92
## Next steps
93
93
94
-
In this quickstart, you created a Resource Graph shared query.
95
-
96
-
To learn more about shared queries, continue to the tutorial for:
94
+
In this quickstart, you created a Resource Graph shared query. To learn more about the Resource Graph language, continue to the query language details page.
97
95
98
96
> [!div class="nextstepaction"]
99
-
> [Manage queries in Azure portal](./tutorials/create-share-query.md)
97
+
> [Understanding the Azure Resource Graph query language](./concepts/query-language.md)
0 commit comments