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
title: 'Quickstart: Run first Azure Resource Graph query in portal'
3
-
description: In this quickstart, you run your first Azure Resource Graph Explorer query using Azure portal.
4
-
ms.date: 03/29/2024
2
+
title: 'Quickstart: Run Resource Graph query using Azure portal'
3
+
description: In this quickstart, you run an Azure Resource Graph query in Azure portal using Azure Resource Graph Explorer.
4
+
ms.date: 04/23/2024
5
5
ms.topic: quickstart
6
6
---
7
7
8
-
# Quickstart: Run your first Resource Graph query using Azure Resource Graph Explorer
8
+
# Quickstart: Run Resource Graph query using Azure portal
9
9
10
-
The power of Azure Resource Graph is available directly in the Azure portal through Azure Resource Graph Explorer. Resource Graph Explorer allows you to query information about the Azure Resource Manager resource types and properties. Resource Graph Explorer also provides an interface for working with multiple queries, evaluating the results, and even converting the results of some queries into a chart that can be pinned to an Azure dashboard.
10
+
This quickstart describes how to run an Azure Resource Graph query in the Azure portal using Azure Resource Graph Explorer. Resource Graph Explorer allows you to query information about the Azure Resource Manager resource types and properties. Resource Graph Explorer also provides an interface for working with multiple queries, evaluating the results, and even converting the results of some queries into a chart that can be pinned to an Azure dashboard.
11
11
12
12
## Prerequisites
13
13
14
14
If you don't have an Azure account, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
15
15
16
-
## Run your first Resource Graph query
16
+
## Run a query
17
17
18
-
Run your first query from the Azure portal using Azure Resource Graph Explorer.
18
+
Run a query from the Azure portal using Azure Resource Graph Explorer.
19
19
20
20
1. Sign in to the [Azure portal](https://portal.azure.com).
21
21
1. Search for _resource graph_ and select **Resource Graph Explorer**.
22
22
23
-
:::image type="content" source="./media/first-query-portal/search-resource-graph.png" alt-text="Screenshot of the Azure portal to search for resource graph.":::
23
+
:::image type="content" source="./media/first-query-portal/search-resource-graph.png" alt-text="Screenshot of the Azure portal to search for resource graph." lightbox="./media/first-query-portal/search-resource-graph.png":::
24
+
25
+
1. If you need to change the scope, select **Directory**. Then select the directory, management group, or subscription for the resources you want to query.
26
+
27
+
:::image type="content" source="./media/first-query-portal/query-scope.png" alt-text="Screenshot of the Azure Resource Graph Explorer to change the scope for directory, management group, or subscription." lightbox="./media/first-query-portal/query-scope.png":::
24
28
25
29
1. In the **Query 1** portion of the window, copy and paste the following query. Then select **Run query**.
26
30
@@ -30,13 +34,13 @@ Run your first query from the Azure portal using Azure Resource Graph Explorer.
30
34
| limit 5
31
35
```
32
36
33
-
:::image type="content" source="./media/first-query-portal/run-query.png" alt-text="Screenshot of Azure Resource Graph Explorer that highlights run query, results, and messages.":::
37
+
:::image type="content" source="./media/first-query-portal/run-query.png" alt-text="Screenshot of Azure Resource Graph Explorer that highlights run query, results, and messages." lightbox="./media/first-query-portal/run-query.png":::
34
38
35
-
This query example doesn't provide a sort modifier like `order by`. If you run this query multiple times, it's likely to yield a different set of resources per request.
39
+
This query example doesn't provide a sort modifier like `order by`. If you run the query multiple times, it might yield a different set of resources for each request.
36
40
37
41
1. Review the query response in the **Results** tab and select the **Messages** tab to see details about the query, including the count of results and duration of the query. Errors, if any, are displayed in **Messages**.
38
42
39
-
1. Update the query to `order by` the **name** property. Then, select **Run query**
43
+
1. Update the query to `order by` the `name` property. Then, select **Run query**
40
44
41
45
```kusto
42
46
resources
@@ -45,9 +49,9 @@ Run your first query from the Azure portal using Azure Resource Graph Explorer.
45
49
| order by name asc
46
50
```
47
51
48
-
Like the first query, running this query multiple times is likely to yield a different set of resources per request. The order of the query commands is important. In this example, the `order by` comes after the `limit`. This command order first limits the query results and then orders them.
52
+
Like the previous query, running this query multiple times might yield a different set of resources for each request. The order of the query commands is important. In this example, the `order by` comes after the `limit`. The query limits the results to five resources and then orders those results by name.
49
53
50
-
1. Update the query to `order by` the **name** property and then `limit` to the top five results. Then, select **Run query**.
54
+
1. Update the query to `order by` the `name` property and then `limit` to the top five results. Then, select **Run query**.
51
55
52
56
```kusto
53
57
resources
@@ -56,7 +60,7 @@ Run your first query from the Azure portal using Azure Resource Graph Explorer.
56
60
| limit 5
57
61
```
58
62
59
-
When the final query is run several times, and with no changes in your environment, the results are consistent and ordered by the **name** property, but still limited to the top five results.
63
+
If this query is run several timeswith no changes to your environment, the results are consistent and ordered by the `name` property, but still limited to five results. The query orders the results by name and then limits the output to five resources.
60
64
61
65
### Schema browser
62
66
@@ -72,19 +76,21 @@ authorizationresources
72
76
| where properties['roleName'] == "INSERT_VALUE_HERE"
73
77
```
74
78
75
-
:::image type="content" source="./media/first-query-portal/schema-browser.png" alt-text="Screenshot of Azure Resource Graph Explorer schema browser that highlights resource type and properties.":::
79
+
:::image type="content" source="./media/first-query-portal/schema-browser.png" alt-text="Screenshot of Azure Resource Graph Explorer schema browser that highlights resource type and properties." lightbox="./media/first-query-portal/schema-browser.png":::
76
80
77
81
## Download query results as a CSV file
78
82
79
83
To download comma-separated values (CSV) results from the Azure portal, browse to the Azure Resource Graph Explorer and run a query. On the toolbar, select **Download as CSV** as shown in the following screenshot:
80
84
81
-
:::image type="content" source="./media/first-query-portal/download-csv.png" alt-text="Screenshot of Azure Resource Graph Explorer with Download as CSV highlighted.":::
85
+
:::image type="content" source="./media/first-query-portal/download-csv.png" alt-text="Screenshot of Azure Resource Graph Explorer with Download as CSV highlighted." lightbox="./media/first-query-portal/download-csv.png":::
82
86
83
87
When you use the **Download as CSV** export functionality of Azure Resource Graph Explorer, the result set is limited to 55,000 records. This limitation is a platform limit that can't be overridden by filing an Azure support ticket.
84
88
85
-
## Create a chart from the Resource Graph query
89
+
## Create a chart from query results
90
+
91
+
You can create charts from queries that output a count for the number of resources. Queries that output lists can't be made into a chart. If you try to create a chart from a list, a message like _the result set isn't compatible with a donut chart visualization_ is displayed in the **Charts** tab.
86
92
87
-
After running the previous query, if you select the **Charts** tab, you get a message that "the result set isn't compatible with a pie chart visualization." Queries that list results can't be made into a chart, but queries that provide counts of resources can.
93
+
To create a chart from query results, do the following steps:
88
94
89
95
1. In the **Query 1** portion of the window, enter the following query and select **Run query**.
90
96
@@ -98,18 +104,19 @@ After running the previous query, if you select the **Charts** tab, you get a me
98
104
99
105
1. Select the **Charts** tab. Change the type from _Select chart type..._ to either _Bar chart_ or _Donut chart_.
100
106
101
-
:::image type="content" source="./media/first-query-portal/query-chart.png" alt-text="Screenshot of Azure Resource Graph Explorer with charts drop-down menu highlighted.":::
107
+
:::image type="content" source="./media/first-query-portal/query-chart.png" alt-text="Screenshot of Azure Resource Graph Explorer with charts drop-down menu highlighted." lightbox="./media/first-query-portal/query-chart.png":::
102
108
103
-
## Pin the query visualization to a dashboard
109
+
## Pin query visualization to dashboard
104
110
105
111
When you have results from a query that can be visualized, that data visualization can be pinned to your Azure portal dashboard. After running the previous query, follow these steps:
106
112
107
-
1. Select **Save** and provide the name _VM by OS type_. Then select **Save** at the bottom of the right pane.
113
+
1. Select **Save** and use the name _Virtual machine by OS type_ and type as _Private queries_. Then select **Save** at the bottom of the right pane.
108
114
1. Select **Run query** to rerun the query you saved.
109
115
1. On the **Charts** tab, select a data visualization. Then select **Pin to dashboard**.
110
116
1. From **Pin to Dashboard** select the existing dashboard where you want the chart to appear.
117
+
1. Select **Dashboard** from the _hamburger menu_ (three horizontal lines) on the top, left side of any portal page.
111
118
112
-
The query is now available on your dashboard with the title **VM by OS type**. If the query wasn't saved before it was pinned, the name is _Query 1_ instead.
119
+
The query is now available on your dashboard with the title **Virtual machine by OS type**. If the query wasn't saved before it was pinned, the name is _Query 1_ instead.
113
120
114
121
The query and resulting data visualization run and update each time the dashboard loads, providing real time and dynamic insights to your Azure environment directly in your workflow.
115
122
@@ -122,12 +129,20 @@ For more information about working with dashboards, see [Create a dashboard in t
122
129
If you want to remove the sample Resource Graph dashboards from your Azure portal environment, do the following steps:
123
130
124
131
1. Select **Dashboard** from the _hamburger menu_ (three horizontal lines) on the top, left side of any portal page.
125
-
1. On your dashboard, find the **VM by OS type** chart and select the ellipsis (`...`) to display the menu.
132
+
1. On your dashboard, find the **Virtual machine by OS type** chart and select the ellipsis (`...`) to display the menu.
126
133
1. Select **Remove from dashboard** select **Save** to confirm.
127
134
135
+
If you want to delete saved queries, like _Virtual machine by OS type_, do the following steps:
136
+
137
+
1. Go to Azure Resource Graph Explorer.
138
+
1. Select **Open a query**.
139
+
1. Select **Type**_Private queries_.
140
+
1. From **Query name** select the rubbish bin icon to **Delete this query**.
141
+
1. Select **Yes** to confirm the deletion.
142
+
128
143
## Next steps
129
144
130
-
In this quickstart, you used Azure Resource Graph Explorer to run your first query and looked at dashboard examples powered by Resource Graph. To learn more about the Resource Graph language, continue to the query language details page.
145
+
In this quickstart, you used Azure Resource Graph Explorer to run a query and reviewed how to use charts and dashboards. To learn more, go to the query language details article.
131
146
132
147
> [!div class="nextstepaction"]
133
148
> [Understanding the Azure Resource Graph query language](./concepts/query-language.md)
0 commit comments