Skip to content

Commit 2c80d2e

Browse files
committed
edit pass: create-share-query
1 parent 9e2ae8c commit 2c80d2e

File tree

1 file changed

+84
-38
lines changed

1 file changed

+84
-38
lines changed

articles/governance/resource-graph/tutorials/create-share-query.md

Lines changed: 84 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ ms.service: resource-graph
99
---
1010
# Tutorial: Create and share an Azure Resource Graph query in the Azure portal
1111

12-
Azure Resource Graph Explorer lets you save your Resource Graph queries directly in the Azure portal. There are two types of queries: _Private_ and _Shared_. A Private query is saved in your Azure portal settings. Whereas a Shared query is a Resource Manager resource that can be managed with role-based
13-
access controls (RBAC) and protected with resource locks.
12+
Azure Resource Graph Explorer lets you save your Resource Graph queries directly in the Azure
13+
portal. There are two types of queries: _Private_ and _Shared_. A Private query is saved in your
14+
Azure portal settings. Whereas a Shared query is a Resource Manager resource that can be managed
15+
with role-based access controls (RBAC) and protected with resource locks.
1416

15-
By saving queries in the Azure portal, you save the time you might otherwise spend looking for your favorite or commonly used queries. When you share queries, you help your team realize goals of consistency and efficiency through repetition.
17+
By saving queries in the Azure portal, you save the time you might otherwise spend looking for your
18+
favorite or commonly used queries. When you share queries, you help your team realize goals of
19+
consistency and efficiency through repetition.
1620

1721
In this tutorial, you'll complete the following tasks:
1822

@@ -24,13 +28,18 @@ In this tutorial, you'll complete the following tasks:
2428
2529
## Prerequisites
2630

27-
To complete this tutorial, you need an Azure subscription. If you don't have one, create a [free account](https://azure.microsoft.com/free/) before you begin.
31+
To complete this tutorial, you need an Azure subscription. If you don't have one, create a
32+
[free account](https://azure.microsoft.com/free/) before you begin.
2833

2934
## Create and delete a Private query
3035

31-
Private queries are accessible and visible only to the account that creates them. As they're saved in an account's Azure portal settings, they can be created, used, and deleted only from inside the Azure portal. A Private query isn't a Resource Manager resource. To create a new Private query, follow these steps:
36+
Private queries are accessible and visible only to the account that creates them. As they're saved
37+
in an account's Azure portal settings, they can be created, used, and deleted only from inside the
38+
Azure portal. A Private query isn't a Resource Manager resource. To create a new Private query,
39+
follow these steps:
3240

33-
1. From the portal menu, select **All services** or use the Azure search box at the top of all pages. Search for and then select **Resource Graph Explorer**.
41+
1. From the portal menu, select **All services** or use the Azure search box at the top of all
42+
pages. Search for and then select **Resource Graph Explorer**.
3443

3544
1. On the **Query 1** tab on the Azure Resource Graph Explorer page, enter the following query:
3645

@@ -46,26 +55,35 @@ Private queries are accessible and visible only to the account that creates them
4655
[Samples – Count virtual machines by OS type](../samples/starter.md#count-virtual-machines-by-os-type).
4756

4857

49-
1. Select **Save** or **Save as**, enter **Count VMs by OS** as the name, leave the type as **Private
50-
query**, and then select **Save** at the bottom of the **Save query** pane. The tab title changes from **Query 1** to **Count VMs by OS**.
58+
1. Select **Save** or **Save as**, enter **Count VMs by OS** as the name, leave the type as
59+
**Private query**, and then select **Save** at the bottom of the **Save query** pane. The tab
60+
title changes from **Query 1** to **Count VMs by OS**.
5161

52-
1. Move away from Azure Resource Graph Explorer in the Azure portal and then return to it. Notice that the saved query is no longer displayed and the **Query 1** tab has returned.
62+
1. Move away from Azure Resource Graph Explorer in the Azure portal and then return to it. Notice
63+
that the saved query is no longer displayed and the **Query 1** tab has returned.
5364

54-
1. Select **Open a query**. Make sure that the type is **Private query**. The saved name **Count VMs by OS** now
55-
appears in the **Query Name** list. When you select the title link of the saved query, it's loaded into a
56-
new tab with that query's name.
65+
1. Select **Open a query**. Make sure that the type is **Private query**. The saved name **Count VMs
66+
by OS** now appears in the **Query Name** list. When you select the title link of the saved
67+
query, it's loaded into a new tab with that query's name.
5768

58-
> [!NOTE]
59-
> When a saved query is open and the tab shows its name, selecting the **Save** button updates it with any changes that have been made. To create a new saved query from this open query, select **Save as** and proceed as if you were saving a brand new query.
69+
> [!NOTE] When a saved query is open and the tab shows its name, selecting the **Save** button
70+
> updates it with any changes that have been made. To create a new saved query from this open
71+
> query, select **Save as** and proceed as if you were saving a brand new query.
6072
61-
1. To delete the saved query, select **Open a query** again, and verify that the **Type** field is set to **Private
62-
query**. On the row of the saved `Count VMs by OS` query, select **Delete** (Recycle bin icon). In the confirmation dialog box, select **Yes** to finish deleting the query. Then, close the **Open a query** pane.
73+
1. To delete the saved query, select **Open a query** again, and verify that the **Type** field is
74+
set to **Private query**. On the row of the saved `Count VMs by OS` query, select **Delete**
75+
(Recycle bin icon). In the confirmation dialog box, select **Yes** to finish deleting the query.
76+
Then, close the **Open a query** pane.
6377

6478
## Create a Shared query
6579

66-
Unlike a Private query, a Shared query is a Resource Manager resource. This fact means the query gets saved to a resource group, can be managed and controlled with RBAC, and can even be protected with resource locks. As a resource, anyone who has the appropriate permissions can see and use it. To create a new Shared query, follow these steps:
80+
Unlike a Private query, a Shared query is a Resource Manager resource. This fact means the query
81+
gets saved to a resource group, can be managed and controlled with RBAC, and can even be protected
82+
with resource locks. As a resource, anyone who has the appropriate permissions can see and use it.
83+
To create a new Shared query, follow these steps:
6784

68-
1. From the portal menu, select **All services**, or use the Azure search box at the top of all pages to search for and select **Resource Graph Explorer**.
85+
1. From the portal menu, select **All services**, or use the Azure search box at the top of all
86+
pages to search for and select **Resource Graph Explorer**.
6987

7088
1. On the **Query 1** tab on the Azure Resource Graph Explorer page, enter the following query:
7189

@@ -78,31 +96,45 @@ Unlike a Private query, a Shared query is a Resource Manager resource. This fact
7896
Select **Run query** to see the query results in the bottom pane.
7997

8098
For more information about this query, see
81-
[Samples – Count virtual machines by OS type](../samples/starter.md#count-virtual-machines-by-os-type).
99+
[Samples – Count virtual machines by OS type](../samples/starter.md#count-virtual-machines-by-os-type).
82100

83101
1. Select **Save** or **Save as**.
84102

103+
85104
![Save the new query using the save button](../media/create-share-query/save-shared-query-buttons.png)
86105

87-
1. In the **Save query** pane, enter **Count VMs by OS** for the name.
88-
1. Change the type to **Shared query**, set the description to **Count of virtual machines by OS type**, and set **Subscription** to specify where the query resource gets created.
89-
1. Leave the **Publish to resource-graph-queries resource group** check box selected and the **Resource Group location** set to **(US) West Central US**.
90-
1. Select
91-
**Save** at the bottom of the **Save query** pane. The tab title changes from **Query 1** to **Count VMs by OS**. The first time the **resource-graph-queries** resource group is used, the save takes longer than expected as the resource group gets created.
106+
1. In the **Save query** pane, enter **Count VMs by OS** for the name.
107+
1. Change the type to **Shared query**, set the description to **Count of virtual machines by OS
108+
type**, and set **Subscription** to specify where the query resource gets created.
109+
1. Leave the **Publish to resource-graph-queries resource group** check box selected and the
110+
**Resource Group location** set to **(US) West Central US**.
111+
1. Select **Save** at the bottom of the **Save query** pane. The tab title changes from **Query 1**
112+
to **Count VMs by OS**. The first time the **resource-graph-queries** resource group is used, the
113+
save takes longer than expected as the resource group gets created.
92114

115+
93116
![Save the new query as a Shared query](../media/create-share-query/save-shared-query-window.png)
94117

95-
> [!NOTE]
96-
> You can clear the **Publish to resource-graph-queries resource group** check box if you want to provide the name of an existing resource group to save the shared query into. Using the default named resource group for queries makes Shared queries easier to discover. It also makes the purpose of that resource group more apparent. However, you might opt to select an existing resource group for security reasons based on existing permissions.
118+
> [!NOTE] You can clear the **Publish to resource-graph-queries resource group** check box if you
119+
> want to provide the name of an existing resource group to save the shared query into. Using the
120+
> default named resource group for queries makes Shared queries easier to discover. It also makes
121+
> the purpose of that resource group more apparent. However, you might opt to select an existing
122+
> resource group for security reasons based on existing permissions.
97123
98-
1. Move away from Azure Resource Graph Explorer in the Azure portal and then return to it. Notice that the saved query is no longer displayed and the **Query 1** tab has returned.
124+
1. Move away from Azure Resource Graph Explorer in the Azure portal and then return to it. Notice
125+
that the saved query is no longer displayed and the **Query 1** tab has returned.
99126

100-
1. Select **Open a query**. Verify that the type is set to **Shared query** and the combination of **Subscription** and **Resource group** match where you saved the query. The saved **Count VMs by OS** item now appears in the **Query Name** list. Select the title link of the saved query to load it into a new tab with that query's name. As a Shared query, it displays an icon in the tab next to the title, denoting it as shared.
127+
1. Select **Open a query**. Verify that the type is set to **Shared query** and the combination of
128+
**Subscription** and **Resource group** match where you saved the query. The saved **Count VMs by
129+
OS** item now appears in the **Query Name** list. Select the title link of the saved query to
130+
load it into a new tab with that query's name. As a Shared query, it displays an icon in the tab
131+
next to the title, denoting it as shared.
101132

102133
![Show the Shared Query with icon](../media/create-share-query/show-saved-shared-query.png)
103134

104-
> [!NOTE]
105-
> When a saved query is open and the tab shows its name, the **Save** button updates it with any changes that have been made. To create a new saved query, select **Save as** and proceed as if you were saving a brand new query.
135+
> [!NOTE] When a saved query is open and the tab shows its name, the **Save** button updates it
136+
> with any changes that have been made. To create a new saved query, select **Save as** and
137+
> proceed as if you were saving a brand new query.
106138
107139
## Discover Shared queries
108140

@@ -115,20 +147,30 @@ Because a Shared query is a Resource Manager resource, there are several ways to
115147

116148
### View Resource Graph queries
117149

118-
In the Azure portal, the Resource Graph queries page displays Shared queries that the logged-in account has access to. This page enables filtering by name, subscription, resource group, and other properties of the Resource Graph query. You can also tag, export, and delete Resource Graph queries by using this interface.
150+
In the Azure portal, the Resource Graph queries page displays Shared queries that the logged-in
151+
account has access to. This page enables filtering by name, subscription, resource group, and other
152+
properties of the Resource Graph query. You can also tag, export, and delete Resource Graph queries
153+
by using this interface.
119154

120-
Selecting one of the queries opens the Resource Graph query page. Like other Resource Manager resources, this page offers an interactive overview along with the Activity log, access control, and tags. You can also apply a resource lock directly from this page.
155+
Selecting one of the queries opens the Resource Graph query page. Like other Resource Manager
156+
resources, this page offers an interactive overview along with the Activity log, access control, and
157+
tags. You can also apply a resource lock directly from this page.
121158

122-
Get to the Resource Graph queries page from the portal menu by selecting **All services** or by using the Azure search box at the top of all pages. Search for and select **Resource Graph Explorer**.
159+
Get to the Resource Graph queries page from the portal menu by selecting **All services** or by
160+
using the Azure search box at the top of all pages. Search for and select **Resource Graph
161+
Explorer**.
123162

124163
### List Resource groups resources
125164

126-
The Resource Graph query is listed alongside other resources that are part of a resource group. Selecting the Resource Graph query opens the page for that query. The ellipsis and shortcut menu options (triggered by right-clicking) work the same as on the Resource Graph query page.
165+
The Resource Graph query is listed alongside other resources that are part of a resource group.
166+
Selecting the Resource Graph query opens the page for that query. The ellipsis and shortcut menu
167+
options (triggered by right-clicking) work the same as on the Resource Graph query page.
127168

128169
### Query Resource Graph
129170

130-
You can find Resource Graph queries through a query to Resource Graph. The following Resource Graph query limits by type `Microsoft.ResourceGraph/queries`, and then uses
131-
`project` to list only the name, time modified, and the query itself:
171+
You can find Resource Graph queries through a query to Resource Graph. The following Resource Graph
172+
query limits by type `Microsoft.ResourceGraph/queries`, and then uses `project` to list only the
173+
name, time modified, and the query itself:
132174

133175
```kusto
134176
Resources
@@ -138,7 +180,10 @@ Resources
138180

139181
## Delete a Shared query
140182

141-
If a Shared query is no longer needed, delete it. By deleting a Shared query, you remove the corresponding Resource Manager resource. Any dashboards that the results chart was pinned to now display an error message. When that error message is displayed, use the **Remove from dashboard** button to clean up your dashboard.
183+
If a Shared query is no longer needed, delete it. By deleting a Shared query, you remove the
184+
corresponding Resource Manager resource. Any dashboards that the results chart was pinned to now
185+
display an error message. When that error message is displayed, use the **Remove from dashboard**
186+
button to clean up your dashboard.
142187

143188
You can delete a Shared query through the following interfaces:
144189
- Resource Graph queries page
@@ -148,7 +193,8 @@ You can delete a Shared query through the following interfaces:
148193

149194
## Clean up resources
150195

151-
When you're finished with this tutorial, delete the Private and Shared queries you created if you no longer want them.
196+
When you're finished with this tutorial, delete the Private and Shared queries you created if you no
197+
longer want them.
152198

153199
## Next steps
154200

0 commit comments

Comments
 (0)