Skip to content

Commit 65cf851

Browse files
author
Jill Grant
authored
Merge pull request #278963 from davidsmatlak/ds-updates-arg-arm-shared-query-20240621
Freshness update for ARG shared query with ARM temlate
2 parents 6bd3083 + 9f0c393 commit 65cf851

File tree

1 file changed

+28
-45
lines changed

1 file changed

+28
-45
lines changed

articles/governance/resource-graph/shared-query-template.md

Lines changed: 28 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,37 @@
11
---
2-
title: 'Quickstart: Create a shared query with templates'
2+
title: 'Quickstart: Create a shared query with ARM template'
33
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-
ms.date: 08/17/2021
4+
ms.date: 06/21/2024
55
ms.topic: quickstart
66
ms.custom: subject-armqs, mode-arm, devx-track-arm-template
77
---
8+
89
# Quickstart: Create a shared query by using an ARM template
910

10-
Resource Graph queries can be saved as a _private query_ or a _shared query_. A private query is
11-
saved to the individuals portal profile and isn't visible to others. A shared query is a Resource
12-
Manager object that can be shared with others through permissions and role-based access. A shared
13-
query provides common and consistent execution of resource discovery. This quickstart uses an Azure
14-
Resource Manager template (ARM template) to create a shared query.
11+
Resource Graph queries can be saved as a _private query_ or a _shared query_. A private query is saved to the individuals portal profile and isn't visible to others. A shared query is a Resource Manager object that can be shared with others through permissions and role-based access. A shared query provides common and consistent execution of resource discovery. This quickstart uses an Azure Resource Manager template (ARM template) to create a shared query.
1512

1613
[!INCLUDE [About Azure Resource Manager](../../../includes/resource-manager-quickstart-introduction.md)]
1714

18-
If your environment meets the prerequisites and you're familiar with using ARM templates, select the
19-
**Deploy to Azure** button. The template will open in the Azure portal.
15+
If your environment meets the prerequisites and you're familiar with using ARM templates, select the **Deploy to Azure** button. The template opens in the Azure portal.
2016

2117
:::image type="content" source="~/reusable-content/ce-skilling/azure/media/template-deployments/deploy-to-azure-button.svg" alt-text="Button to deploy the Resource Manager template to Azure." border="false" link="https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2Fdemos%2Fresourcegraph-sharedquery-countos%2Fazuredeploy.json":::
2218

2319
## Prerequisites
2420

25-
If you don't have an Azure subscription, create a [free](https://azure.microsoft.com/free/) account
26-
before you begin.
21+
If you don't have an Azure subscription, create a [free](https://azure.microsoft.com/free/) account before you begin.
2722

2823
## Review the template
2924

30-
In this quickstart, you create a shared query called _Count VMs by OS_. To try this query in SDK or
31-
in portal with Resource Graph Explorer, see
32-
[Samples - Count virtual machines by OS type](./samples/starter.md#count-virtual-machines-by-os-type).
25+
In this quickstart, you create a shared query called _Count VMs by OS_. To try this query in SDK or in portal with Resource Graph Explorer, go to [Samples - Count virtual machines by OS type](./samples/starter.md#count-virtual-machines-by-os-type).
3326

34-
The template used in this quickstart is from [Azure Quickstart Templates](https://azure.microsoft.com/resources/templates/resourcegraph-sharedquery-countos/).
27+
The template used in this quickstart is from [Azure Quickstart Templates](/samples/azure/azure-quickstart-templates/resourcegraph-sharedquery-countos/).
3528

3629
:::code language="json" source="~/quickstart-templates/demos/resourcegraph-sharedquery-countos/azuredeploy.json":::
3730

38-
The resource defined in the template is:
39-
40-
- [Microsoft.ResourceGraph/queries](/azure/templates/microsoft.resourcegraph/queries)
31+
The resource defined in the template is [Microsoft.ResourceGraph/queries](/azure/templates/microsoft.resourcegraph/queries).
4132

4233
## Deploy the template
4334

44-
> [!NOTE]
45-
> Azure Resource Graph service is free. For more information, see
46-
> [Overview of Azure Resource Graph](./overview.md).
47-
4835
1. Select the following image to sign in to the Azure portal and open the template:
4936

5037
:::image type="content" source="~/reusable-content/ce-skilling/azure/media/template-deployments/deploy-to-azure-button.svg" alt-text="Button to deploy the Resource Manager template to Azure." border="false" link="https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2Fdemos%2Fresourcegraph-sharedquery-countos%2Fazuredeploy.json":::
@@ -54,19 +41,19 @@ The resource defined in the template is:
5441
| Name | Value |
5542
|------|-------|
5643
| Subscription | Select your Azure subscription. |
57-
| Resource group | Select **Create new**, specify a name, and then select **OK**. |
58-
| Location | Select a region. For example, **Central US**. |
59-
| Query name | Leave the default value: **Count VMs by OS**. |
60-
| Query code | Leave the default value: `Resources | where type =~ 'Microsoft.Compute/virtualMachines' | summarize count() by tostring(properties.storageProfile.osDisk.osType)` |
61-
| Query description | Leave the default value: **This shared query counts all virtual machine resources and summarizes by the OS type.** |
62-
| I agree to the terms and conditions stated above | (Select) |
44+
| Resource group | Select **Create new**, specify a name, and then select **OK**. Or select an existing resource group. |
45+
| Location | Select a region. For example, **West US**. |
46+
| Query name | Use the default value: **Count VMs by OS**. |
47+
| Query code | Use the default value: `Resources | where type =~ 'Microsoft.Compute/virtualMachines' | summarize count() by tostring(properties.storageProfile.osDisk.osType)` |
48+
| Query description | Use the default value: **This shared query counts all virtual machine resources and summarizes by the OS type.** |
6349

64-
1. Select **Purchase**.
50+
1. Select **Review + create**.
51+
1. Select **Create**.
6552

6653
Some other resources:
6754

68-
- To find more samples templates, see
69-
[Azure Quickstart Template](https://azure.microsoft.com/resources/templates/?resourceType=Microsoft.Authorization&pageNumber=1&sort=Popular).
55+
- To find more sample templates, see
56+
[Browse code samples](/samples/browse/?expanded=azure&products=azure-resource-manager).
7057
- To see the template reference, go to
7158
[Azure template reference](/azure/templates/microsoft.resourcegraph/allversions).
7259
- To learn how to develop ARM templates, see
@@ -78,33 +65,29 @@ Some other resources:
7865

7966
To run the new shared query, follow these steps:
8067

81-
1. From the portal search bar, search for **Resource Graph queries** and select it.
82-
68+
1. From the portal search bar, search for _Resource Graph queries_ and select it.
8369
1. Select the shared query named **Count VMs by OS**, then select the **Results** tab on the
8470
**Overview** page.
8571

8672
The shared query can also be opened from Resource Graph Explorer:
8773

88-
1. From the portal search bar, search for **Resource Graph Explorer** and select it.
89-
90-
1. Select the **Open a query** button.
91-
74+
1. From the portal search bar, search for _Resource Graph Explorer_ and select it.
75+
1. Select the **Open a query**.
9276
1. Change **Type** to _Shared queries_. If you don't see the **Count VMs by OS** in the list, use
93-
the filter box to limit the results. Once the **Count VMs by OS** shared query is visible, select
94-
its name.
77+
the filter box to limit the results by **Subscription** or **Resource group**. When the **Count VMs by OS** shared query is visible, select its name.
78+
1. Select **Run query** and results are displayed in the **Results** tab.
9579

96-
1. Once the query is loaded, select the **Run query** button. Results are displayed in the
97-
**Results** tab.
80+
In Resource Graph Explorer, on left side of page, you can change the **Scope** to use _Directory_, _Management group_, or _Subscription_.
9881

9982
## Clean up resources
10083

10184
To remove the shared query created, follow these steps:
10285

103-
1. From the portal search bar, search for **Resource Graph queries** and select it.
104-
86+
1. From the portal search bar, search for _Resource Graph queries_ and select it.
10587
1. Set the check box next to the shared query named **Count VMs by OS**.
106-
107-
1. Select the **Delete** button along the top of the page.
88+
1. Select **Delete**.
89+
1. Enter _delete_ and select **Delete**.
90+
1. Select **Delete** from the confirmation prompt.
10891

10992
## Next steps
11093

0 commit comments

Comments
 (0)