你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。

Microsoft.OperationalInsights 查询包/查询

Bicep 资源定义

可以使用目标作部署 queryPacks/query 资源类型:

有关每个 API 版本中已更改属性的列表,请参阅 更改日志。

用法示例

Bicep 示例

部署 Log Analytics 查询包查询的基本示例。

param resourceName string = 'acctest0001'
param location string = 'westeurope'

resource queryPack 'Microsoft.OperationalInsights/queryPacks@2019-09-01' = {
  name: resourceName
  location: location
  properties: {}
}

resource query 'Microsoft.OperationalInsights/queryPacks/queries@2019-09-01' = {
  name: 'aca50e92-d3e6-8f7d-1f70-2ec7adc1a926'
  parent: queryPack
  properties: {
    body: '''    let newExceptionsTimeRange = 1d;
    let timeRangeToCheckBefore = 7d;
    exceptions
    | where timestamp < ago(timeRangeToCheckBefore)
    | summarize count() by problemId
    | join kind= rightanti (
        exceptions
        | where timestamp >= ago(newExceptionsTimeRange)
        | extend stack = tostring(details[0].rawStack)
        | summarize count(), dcount(user_AuthenticatedId), min(timestamp), max(timestamp), any(stack) by problemId
    ) on problemId
    | order by count_ desc
'''
    displayName: 'Exceptions - New in the last 24 hours'
    related: {}
  }
}

资源格式

若要创建 Microsoft.OperationalInsights/queryPacks/query 资源,请将以下 Bicep 添加到模板。

resource symbolicname 'Microsoft.OperationalInsights/queryPacks/queries@2026-03-01' = {
  parent: resourceSymbolicName
  name: 'string'
  properties: {
    body: 'string'
    description: 'string'
    displayName: 'string'
    properties: any(...)
    related: {
      categories: [
        'string'
      ]
      resourceTypes: [
        'string'
      ]
      solutions: [
        'string'
      ]
    }
    tags: {
      {customized property}: [
        'string'
      ]
    }
  }
}

属性值

Microsoft.OperationalInsights/queryPacks/queries

名称 DESCRIPTION 价值
姓名 资源名称 string (必需)
父级 在 Bicep 中,可以为子资源指定父资源。 仅当子资源在父资源外部声明时,才需要添加此属性。

有关详细信息,请参阅 父资源外部的子资源。
类型资源的符号名称: queryPacks
属性 定义 Log Analytics QueryPack-Query 资源的属性。 LogAnalyticsQueryPackQueryProperties

LogAnalyticsQueryPackQueryProperties

名称 DESCRIPTION 价值
身体 查询正文。 string (必需)
描述 查询的说明。 字符串
displayName (显示名称) 查询包中查询的唯一显示名称。 string (必需)
属性 可为查询设置的其他属性。 任何
相关 函数的相关元数据项。 LogAnalyticsQueryPackQueryProperties相关
标签 与查询关联的标记。 LogAnalyticsQueryPackQueryProperties标签

LogAnalyticsQueryPackQueryProperties相关

名称 DESCRIPTION 价值
类别 函数的相关类别。 字符串[]
资源类型 函数的相关资源类型。 字符串[]
解决方案 函数的相关 Log Analytics 解决方案。 字符串[]

LogAnalyticsQueryPackQueryProperties标签

名称 DESCRIPTION 价值

ARM 模板资源定义

可以使用目标作部署 queryPacks/query 资源类型:

用法示例

资源格式

若要创建 Microsoft.OperationalInsights/queryPacks/query 资源,请将以下 JSON 添加到模板。

{
  "type": "Microsoft.OperationalInsights/queryPacks/queries",
  "apiVersion": "2026-03-01",
  "name": "string",
  "properties": {
    "body": "string",
    "description": "string",
    "displayName": "string",
    "properties": {},
    "related": {
      "categories": [ "string" ],
      "resourceTypes": [ "string" ],
      "solutions": [ "string" ]
    },
    "tags": {
      "{customized property}": [ "string" ]
    }
  }
}

属性值

Microsoft.OperationalInsights/queryPacks/queries

名称 DESCRIPTION 价值
apiVersion API 版本 '2026-03-01'
姓名 资源名称 string (必需)
属性 定义 Log Analytics QueryPack-Query 资源的属性。 LogAnalyticsQueryPackQueryProperties
类型 资源类型 “Microsoft.OperationalInsights/queryPacks/queries”

LogAnalyticsQueryPackQueryProperties

名称 DESCRIPTION 价值
身体 查询正文。 string (必需)
描述 查询的说明。 字符串
displayName (显示名称) 查询包中查询的唯一显示名称。 string (必需)
属性 可为查询设置的其他属性。 任何
相关 函数的相关元数据项。 LogAnalyticsQueryPackQueryProperties相关
标签 与查询关联的标记。 LogAnalyticsQueryPackQueryProperties标签

LogAnalyticsQueryPackQueryProperties相关

名称 DESCRIPTION 价值
类别 函数的相关类别。 字符串[]
资源类型 函数的相关资源类型。 字符串[]
解决方案 函数的相关 Log Analytics 解决方案。 字符串[]

LogAnalyticsQueryPackQueryProperties标签

名称 DESCRIPTION 价值

Terraform (AzAPI 提供程序)资源定义

可以使用目标作部署 queryPacks/query 资源类型:

  • 资源组 关于每个API版本中变更属性的列表,请参见 更改日志。

用法示例

Terraform 示例

部署 Log Analytics 查询包查询的基本示例。

terraform {
  required_providers {
    azapi = {
      source = "Azure/azapi"
    }
  }
}

provider "azapi" {
  skip_provider_registration = false
}

variable "resource_name" {
  type    = string
  default = "acctest0001"
}

variable "location" {
  type    = string
  default = "westeurope"
}

resource "azapi_resource" "resourceGroup" {
  type     = "Microsoft.Resources/resourceGroups@2020-06-01"
  name     = var.resource_name
  location = var.location
}

resource "azapi_resource" "queryPack" {
  type      = "Microsoft.OperationalInsights/queryPacks@2019-09-01"
  parent_id = azapi_resource.resourceGroup.id
  name      = var.resource_name
  location  = var.location
  body = {
    properties = {
    }

  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

resource "azapi_resource" "query" {
  type      = "Microsoft.OperationalInsights/queryPacks/queries@2019-09-01"
  parent_id = azapi_resource.queryPack.id
  name      = "aca50e92-d3e6-8f7d-1f70-2ec7adc1a926"
  body = {
    properties = {
      body        = "    let newExceptionsTimeRange = 1d;\n    let timeRangeToCheckBefore = 7d;\n    exceptions\n    | where timestamp < ago(timeRangeToCheckBefore)\n    | summarize count() by problemId\n    | join kind= rightanti (\n        exceptions\n        | where timestamp >= ago(newExceptionsTimeRange)\n        | extend stack = tostring(details[0].rawStack)\n        | summarize count(), dcount(user_AuthenticatedId), min(timestamp), max(timestamp), any(stack) by problemId\n    ) on problemId\n    | order by count_ desc\n"
      displayName = "Exceptions - New in the last 24 hours"
      related = {
      }
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

资源格式

若要创建 Microsoft.OperationalInsights/queryPacks/query 资源,请将以下 Terraform 添加到模板。

resource "azapi_resource" "symbolicname" {
  type = "Microsoft.OperationalInsights/queryPacks/queries@2026-03-01"
  name = "string"
  parent_id = "string"
  body = {
    properties = {
      body = "string"
      description = "string"
      displayName = "string"
      properties = ?
      related = {
        categories = [
          "string"
        ]
        resourceTypes = [
          "string"
        ]
        solutions = [
          "string"
        ]
      }
      tags = {
        {customized property} = [
          "string"
        ]
      }
    }
  }
}

属性值

Microsoft.OperationalInsights/queryPacks/queries

名称 DESCRIPTION 价值
姓名 资源名称 string (必需)
parent_id 此资源的父资源的 ID。 类型资源的 ID: queryPacks
属性 定义 Log Analytics QueryPack-Query 资源的属性。 LogAnalyticsQueryPackQueryProperties
类型 资源类型 “Microsoft。操作洞察/查询包/queries@2026-03-01”

LogAnalyticsQueryPackQueryProperties

名称 DESCRIPTION 价值
身体 查询正文。 string (必需)
描述 查询的说明。 字符串
displayName (显示名称) 查询包中查询的唯一显示名称。 string (必需)
属性 可为查询设置的其他属性。 任何
相关 函数的相关元数据项。 LogAnalyticsQueryPackQueryProperties相关
标签 与查询关联的标记。 LogAnalyticsQueryPackQueryProperties标签

LogAnalyticsQueryPackQueryProperties相关

名称 DESCRIPTION 价值
类别 函数的相关类别。 字符串[]
资源类型 函数的相关资源类型。 字符串[]
解决方案 函数的相关 Log Analytics 解决方案。 字符串[]

LogAnalyticsQueryPackQueryProperties标签

名称 DESCRIPTION 价值