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@2024-04-01' = {
  etag: 'string'
  location: 'string'
  name: 'string'
  properties: {
    description: 'string'
    query: 'string'
  }
  tags: {
    {customized property}: 'string'
  }
}

Property values

GraphQueryProperties

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

Microsoft.ResourceGraph/queries

Name Description Value
etag This will be used to handle Optimistic Concurrency. If not present, it will always overwrite the existing resource without checking conflict. string
location The location of the resource string
name The resource name string

Constraints:
Pattern = ^[^<>&:\?]*$ (required)
properties Metadata describing a graph query for an Azure resource. GraphQueryProperties
tags Resource tags Dictionary of tag names and values. See Tags in templates

ResourceTags

Name Description Value

Quickstart samples

The following quickstart samples deploy this resource type.

Bicep File Description
Resource Graph Shared Query - Count OS 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": "2024-04-01",
  "name": "string",
  "etag": "string",
  "location": "string",
  "properties": {
    "description": "string",
    "query": "string"
  },
  "tags": {
    "{customized property}": "string"
  }
}

Property values

GraphQueryProperties

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

Microsoft.ResourceGraph/queries

Name Description Value
apiVersion The api version '2024-04-01'
etag This will be used to handle Optimistic Concurrency. If not present, it will always overwrite the existing resource without checking conflict. string
location The location of the resource string
name The resource name string

Constraints:
Pattern = ^[^<>&:\?]*$ (required)
properties Metadata describing a graph query for an Azure resource. GraphQueryProperties
tags Resource tags Dictionary of tag names and values. See Tags in templates
type The resource type 'Microsoft.ResourceGraph/queries'

ResourceTags

Name Description Value

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@2024-04-01"
  name = "string"
  etag = "string"
  location = "string"
  tags = {
    {customized property} = "string"
  }
  body = jsonencode({
    properties = {
      description = "string"
      query = "string"
    }
  })
}

Property values

GraphQueryProperties

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

Microsoft.ResourceGraph/queries

Name Description Value
etag This will be used to handle Optimistic Concurrency. If not present, it will always overwrite the existing resource without checking conflict. string
location The location of the resource string
name The resource name string

Constraints:
Pattern = ^[^<>&:\?]*$ (required)
properties Metadata describing a graph query for an Azure resource. GraphQueryProperties
tags Resource tags Dictionary of tag names and values.
type The resource type "Microsoft.ResourceGraph/queries@2024-04-01"

ResourceTags

Name Description Value