Microsoft.ResourceGraph queries

Bicep resource definition

The queries resource type can be deployed with operations that target:

For a list of changed properties in each API version, see change log.

Resource format

To create a Microsoft.ResourceGraph/queries resource, add the following Bicep to your template.

resource symbolicname 'Microsoft.ResourceGraph/queries@2018-09-01-preview' = {
  name: 'string'
  location: 'string'
  tags: {
    tagName1: 'tagValue1'
    tagName2: 'tagValue2'
  }
  etag: 'string'
  properties: {
    description: 'string'
    query: 'string'
  }
}

Property values

queries

Name Description Value
name The resource name string (required)
location The location of the resource string
tags Resource tags Dictionary of tag names and values. See Tags in templates
etag This will be used to handle Optimistic Concurrency. If not present, it will always overwrite the existing resource without checking conflict. string
properties Metadata describing a graph query for an Azure resource. GraphQueryProperties

GraphQueryProperties

Name Description Value
description The description of a graph query. string
query KQL query that will be graph. string (required)

Quickstart templates

The following quickstart templates deploy this resource type.

Template Description
Resource Graph Shared Query - Count OS

Deploy to Azure
This template deploys an Azure Resource Graph shared query. The shared query counts all virtual machine resources and summarizes by the OS type. A shared query can be pinned to a dashboard or converted to a supported visualization such as a bar or pie chart.

ARM template resource definition

The queries resource type can be deployed with operations that target:

For a list of changed properties in each API version, see change log.

Resource format

To create a Microsoft.ResourceGraph/queries resource, add the following JSON to your template.

{
  "type": "Microsoft.ResourceGraph/queries",
  "apiVersion": "2018-09-01-preview",
  "name": "string",
  "location": "string",
  "tags": {
    "tagName1": "tagValue1",
    "tagName2": "tagValue2"
  },
  "etag": "string",
  "properties": {
    "description": "string",
    "query": "string"
  }
}

Property values

queries

Name Description Value
type The resource type 'Microsoft.ResourceGraph/queries'
apiVersion The resource api version '2018-09-01-preview'
name The resource name string (required)
location The location of the resource string
tags Resource tags Dictionary of tag names and values. See Tags in templates
etag This will be used to handle Optimistic Concurrency. If not present, it will always overwrite the existing resource without checking conflict. string
properties Metadata describing a graph query for an Azure resource. GraphQueryProperties

GraphQueryProperties

Name Description Value
description The description of a graph query. string
query KQL query that will be graph. string (required)

Quickstart templates

The following quickstart templates deploy this resource type.

Template Description
Resource Graph Shared Query - Count OS

Deploy to Azure
This template deploys an Azure Resource Graph shared query. The shared query counts all virtual machine resources and summarizes by the OS type. A shared query can be pinned to a dashboard or converted to a supported visualization such as a bar or pie chart.

Terraform (AzAPI provider) resource definition

The queries resource type can be deployed with operations that target:

  • Resource groups

For a list of changed properties in each API version, see change log.

Resource format

To create a Microsoft.ResourceGraph/queries resource, add the following Terraform to your template.

resource "azapi_resource" "symbolicname" {
  type = "Microsoft.ResourceGraph/queries@2018-09-01-preview"
  name = "string"
  location = "string"
  parent_id = "string"
  tags = {
    tagName1 = "tagValue1"
    tagName2 = "tagValue2"
  }
  body = jsonencode({
    properties = {
      description = "string"
      query = "string"
    }
    etag = "string"
  })
}

Property values

queries

Name Description Value
type The resource type "Microsoft.ResourceGraph/queries@2018-09-01-preview"
name The resource name string (required)
location The location of the resource string
parent_id To deploy to a resource group, use the ID of that resource group. string (required)
tags Resource tags Dictionary of tag names and values.
etag This will be used to handle Optimistic Concurrency. If not present, it will always overwrite the existing resource without checking conflict. string
properties Metadata describing a graph query for an Azure resource. GraphQueryProperties

GraphQueryProperties

Name Description Value
description The description of a graph query. string
query KQL query that will be graph. string (required)