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

名稱 說明 價值觀
名稱 資源名稱 字串 (必要)
父代 在 Bicep 中,您可以指定子資源的父資源。 只有在父資源外部宣告子資源時,才需要新增這個屬性。

如需詳細資訊,請參閱 父資源外部的子資源。
類型的資源符號名稱:queryPacks
屬性 定義Log Analytics QueryPack-Query 資源的屬性。 LogAnalyticsQueryPackQueryProperties

LogAnalyticsQueryPackQueryProperties

名稱 說明 價值觀
身體 查詢的主體。 字串 (必要)
說明 查詢的描述。 字串
顯示名稱 查詢套件內查詢的唯一顯示名稱。 字串 (必要)
屬性 可針對查詢設定的其他屬性。 任何
相關 函式的相關元數據專案。 LogAnalyticsQueryPackQueryProperties相關
標記 與查詢相關聯的標記。 LogAnalyticsQueryPackQueryProperties標籤

LogAnalyticsQueryPackQueryProperties相關

名稱 說明 價值觀
類別 函式的相關類別。 字串[]
resourceTypes 函式的相關資源類型。 字串[]
解決方案 函式的相關Log Analytics解決方案。 字串[]

LogAnalyticsQueryPackQueryProperties標籤

名稱 說明 價值觀

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

名稱 說明 價值觀
apiVersion API 版本 '2026-03-01'
名稱 資源名稱 字串 (必要)
屬性 定義Log Analytics QueryPack-Query 資源的屬性。 LogAnalyticsQueryPackQueryProperties
型別 資源類型 “Microsoft.OperationalInsights/queryPacks/queries”

LogAnalyticsQueryPackQueryProperties

名稱 說明 價值觀
身體 查詢的主體。 字串 (必要)
說明 查詢的描述。 字串
顯示名稱 查詢套件內查詢的唯一顯示名稱。 字串 (必要)
屬性 可針對查詢設定的其他屬性。 任何
相關 函式的相關元數據專案。 LogAnalyticsQueryPackQueryProperties相關
標記 與查詢相關聯的標記。 LogAnalyticsQueryPackQueryProperties標籤

LogAnalyticsQueryPackQueryProperties相關

名稱 說明 價值觀
類別 函式的相關類別。 字串[]
resourceTypes 函式的相關資源類型。 字串[]
解決方案 函式的相關Log Analytics解決方案。 字串[]

LogAnalyticsQueryPackQueryProperties標籤

名稱 說明 價值觀

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

名稱 說明 價值觀
名稱 資源名稱 字串 (必要)
父項識別碼 此資源為父系之資源的標識碼。 類型的資源標識碼:queryPacks
屬性 定義Log Analytics QueryPack-Query 資源的屬性。 LogAnalyticsQueryPackQueryProperties
型別 資源類型 「Microsoft。操作洞察/查詢包/queries@2026-03-01」

LogAnalyticsQueryPackQueryProperties

名稱 說明 價值觀
身體 查詢的主體。 字串 (必要)
說明 查詢的描述。 字串
顯示名稱 查詢套件內查詢的唯一顯示名稱。 字串 (必要)
屬性 可針對查詢設定的其他屬性。 任何
相關 函式的相關元數據專案。 LogAnalyticsQueryPackQueryProperties相關
標記 與查詢相關聯的標記。 LogAnalyticsQueryPackQueryProperties標籤

LogAnalyticsQueryPackQueryProperties相關

名稱 說明 價值觀
類別 函式的相關類別。 字串[]
resourceTypes 函式的相關資源類型。 字串[]
解決方案 函式的相關Log Analytics解決方案。 字串[]

LogAnalyticsQueryPackQueryProperties標籤

名稱 說明 價值觀