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
LogAnalyticsQueryPackQueryProperties
| 名称 |
DESCRIPTION |
价值 |
| 类别 |
函数的相关类别。 |
字符串[] |
| 资源类型 |
函数的相关资源类型。 |
字符串[] |
| 解决方案 |
函数的相关 Log Analytics 解决方案。 |
字符串[] |
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 |
价值 |
| 类别 |
函数的相关类别。 |
字符串[] |
| 资源类型 |
函数的相关资源类型。 |
字符串[] |
| 解决方案 |
函数的相关 Log Analytics 解决方案。 |
字符串[] |
可以使用目标作部署 queryPacks/query 资源类型:
-
资源组 关于每个API版本中变更属性的列表,请参见 更改日志。
用法示例
部署 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
LogAnalyticsQueryPackQueryProperties
| 名称 |
DESCRIPTION |
价值 |
| 类别 |
函数的相关类别。 |
字符串[] |
| 资源类型 |
函数的相关资源类型。 |
字符串[] |
| 解决方案 |
函数的相关 Log Analytics 解决方案。 |
字符串[] |