Skip to content

Commit e359f9d

Browse files
authored
Merge pull request #112543 from DCtheGeek/dmc-arg-armtemplate
New Resource Graph ARM template
2 parents cbfa371 + efe0565 commit e359f9d

File tree

3 files changed

+121
-4
lines changed

3 files changed

+121
-4
lines changed

articles/governance/index.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,6 @@ additionalContent:
180180
url: /cli/azure/ext/resource-graph/graph
181181
- text: Azure PowerShell
182182
url: /powershell/module/az.resourcegraph/
183-
- text: Azure PowerShell
184-
url: https://www.powershellgallery.com/packages/Az.ResourceGraph
185-
note: (PS Gallery Module)
186183
- text: Azure SDK for .NET
187184
url: /dotnet/api/Microsoft.Azure.Management.ResourceGraph
188185
- text: Azure SDK for .NET
@@ -204,6 +201,8 @@ additionalContent:
204201
note: (Gem)
205202
- text: REST
206203
url: /rest/api/azure-resourcegraph/
204+
- text: Resource Manager templates
205+
url: /azure/templates/microsoft.resourcegraph/allversions
207206
- title: Cost Management
208207
links:
209208
- text: REST
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
---
2+
title: "Quickstart: Create a shared query with templates"
3+
description: In this quickstart, you use a Resource Manager template to create a Resource Graph shared query that counts virtual machines by OS.
4+
ms.date: 04/28/2020
5+
ms.topic: quickstart
6+
ms.custom: subject-armqs
7+
---
8+
# Quickstart: Create a shared query by using a Resource Manager template
9+
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 a
14+
Resource Manager template to create a shared query.
15+
16+
[!INCLUDE [About Azure Resource Manager](../../../includes/resource-manager-quickstart-introduction.md)]
17+
18+
## Prerequisites
19+
20+
If you don't have an Azure subscription, create a [free](https://azure.microsoft.com/free/) account
21+
before you begin.
22+
23+
## Create a shared query
24+
25+
In this quickstart, you create a shared query called _Count VMs by OS_. To try this query in SDK or
26+
in portal with Resource Graph Explorer, see
27+
[Samples - Count virtual machines by OS type](./samples/starter.md#count-os).
28+
29+
### Review the template
30+
31+
The template used in this quickstart is from [Azure Quickstart templates](https://azure.microsoft.com/resources/templates/resourcegraph-sharedquery-countos/).
32+
33+
:::code language="json" source="~/quickstart-templates/resourcegraph-sharedquery-countos/azuredeploy.json" highlight="28-37":::
34+
35+
The resource defined in the template is:
36+
37+
- [Microsoft.ResourceGraph/queries](/azure/templates/microsoft.resourcegraph/queries)
38+
39+
### Deploy the template
40+
41+
> [!NOTE]
42+
> Azure Resource Graph service is free. For more information, see
43+
> [Overview of Azure Resource Graph](./overview.md).
44+
45+
1. Select the following image to sign in to the Azure portal and open the template:
46+
47+
[![Deploy the Policy template to Azure](../../media/template-deployments/deploy-to-azure.svg)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2Fresourcegraph-sharedquery-countos%2Fazuredeploy.json)
48+
49+
1. Select or enter the following values:
50+
51+
| Name | Value |
52+
|------|-------|
53+
| Subscription | Select your Azure subscription. |
54+
| Resource group | Select **Create new**, specify a name, and then select **OK**. |
55+
| Location | Select a region. For example, **Central US**. |
56+
| Query name | Leave the default value **Count VMs by OS**. |
57+
| Query code | Leave the default value `Resources | where type =~ 'Microsoft.Compute/virtualMachines' | summarize count() by tostring(properties.storageProfile.osDisk.osType)` |
58+
| Query description | Leave the default value **This shared query counts all virtual machine resources and summarizes by the OS type.** |
59+
| I agree to the terms and conditions stated above | (Select) |
60+
61+
1. Select **Purchase**.
62+
63+
Some additional resources:
64+
65+
- To find more samples templates, see
66+
[Azure Quickstart template](https://azure.microsoft.com/resources/templates/?resourceType=Microsoft.Authorization&pageNumber=1&sort=Popular).
67+
- To see the template reference, go to
68+
[Azure template reference](/azure/templates/microsoft.resourcegraph/allversions).
69+
- To learn how to develop Resource Manager templates, see
70+
[Azure Resource Manager documentation](../../azure-resource-manager/management/overview.md).
71+
- To learn subscription-level deployment, see
72+
[Create resource groups and resources at the subscription level](../../azure-resource-manager/templates/deploy-to-subscription.md).
73+
74+
## Validate the deployment
75+
76+
To run the new shared query, follow these steps:
77+
78+
1. From the portal search bar, search for **Resource Graph queries** and select it.
79+
80+
1. Select the shared query named **Count VMs by OS**, then select the **Results** tab on the
81+
**Overview** page.
82+
83+
Alternatively, the shared query can be opened from Resource Graph Explorer:
84+
85+
1. From the portal search bar, search for **Resource Graph Explorer** and select it.
86+
87+
1. Select the **Open a query** button.
88+
89+
1. Change **Type** to _Shared queries_. If you don't see the **Count VMs by OS** in the list, use
90+
the filter box to limit the results. Once the **Count VMs by OS** shared query is visible, select
91+
its name.
92+
93+
1. Once the query is loaded, select the **Run query** button. Results are displayed in the
94+
**Results** tab below.
95+
96+
## Clean up resources
97+
98+
To remove the shared query created, follow these steps:
99+
100+
1. From the portal search bar, search for **Resource Graph queries** and select it.
101+
102+
1. Set the check box next to the shared query named **Count VMs by OS**.
103+
104+
1. Select the **Delete** button along the top of the page.
105+
106+
## Next steps
107+
108+
In this quickstart, you created a Resource Graph shared query.
109+
110+
To learn more about shared queries, continue to the tutorial for:
111+
112+
> [!div class="nextstepaction"]
113+
> [Manage queries in Azure portal](./tutorials/create-share-query.md)

articles/governance/resource-graph/toc.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
- name: Run your first query - PowerShell
1818
displayName: module, docker, Az.ResourceGraph
1919
href: first-query-powershell.md
20+
- name: Deploy a shared query - ARM template
21+
displayName: resource manager, queries
22+
href: shared-query-template.md
2023
- name: Tutorials
2124
items:
2225
- name: Create and share a query in Azure portal
@@ -77,7 +80,9 @@
7780
- name: REST
7881
href: /rest/api/azure-resourcegraph/
7982
- name: OpenAPI
80-
href: https://github.com/Azure/azure-rest-api-specs/tree/master/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/stable/2019-04-01
83+
href: https://github.com/Azure/azure-rest-api-specs/tree/master/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/stable/2019-04-01
84+
- name: Resource Manager templates
85+
href: /azure/templates/microsoft.resourcegraph/allversions
8186
- name: Resource Graph tables and resource types
8287
href: ./reference/supported-tables-resources.md
8388
- name: Resources

0 commit comments

Comments
 (0)