你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Bicep资源定义
可以使用目标操作部署 actionRules 资源类型:
- 资源组 - 请参阅 资源组部署命令
有关每个 API 版本中已更改属性的列表,请参阅 更改日志。
用法示例
Bicep 样本
部署应用作组的警报处理规则的基本示例。
param resourceName string = 'acctest0001'
param location string = 'westeurope'
resource actionRule 'Microsoft.AlertsManagement/actionRules@2021-08-08' = {
name: resourceName
location: 'global'
properties: {
actions: [
{
actionType: 'RemoveAllActionGroups'
}
]
description: ''
enabled: true
scopes: [
resourceGroup().id
]
}
}
Azure verified modules
以下 Azure 验证模块可用于部署该资源类型。
| Module | Description |
|---|---|
| 动作规则 | 作规则的 AVM 资源模块 |
Azure 快速入门示例
以下Azure快速启动模板包含部署该资源类型的Bicep示例。
| Bicep 文件 | Description |
|---|---|
| 设置备份警报通知,使用Azure Monitor | 该模板允许您通过部署警报处理规则和动作组,为您的恢复服务保险库设置电子邮件通知Azure Monitor |
资源格式
要创建 Microsoft.AlertsManagement/actionRules 资源,请将以下 Bicep 添加到模板中。
resource symbolicname 'Microsoft.AlertsManagement/actionRules@2021-08-08' = {
location: 'string'
name: 'string'
properties: {
actions: [
{
actionType: 'string'
// For remaining properties, see Action objects
}
]
conditions: [
{
field: 'string'
operator: 'string'
values: [
'string'
]
}
]
description: 'string'
enabled: bool
schedule: {
effectiveFrom: 'string'
effectiveUntil: 'string'
recurrences: [
{
endTime: 'string'
startTime: 'string'
recurrenceType: 'string'
// For remaining properties, see Recurrence objects
}
]
timeZone: 'string'
}
scopes: [
'string'
]
}
tags: {
{customized property}: 'string'
}
}
作对象
设置 actionType 属性以指定对象的类型。
对于 AddActionGroups,请使用:
{
actionGroupIds: [
'string'
]
actionType: 'AddActionGroups'
}
对于 RemoveAllActionGroups,请使用:
{
actionType: 'RemoveAllActionGroups'
}
重复对象
设置 recurrenceType 属性以指定对象的类型。
对于 日常,请使用:
{
recurrenceType: 'Daily'
}
对于 每月,请使用:
{
daysOfMonth: [
int
]
recurrenceType: 'Monthly'
}
对于 每周,请使用:
{
daysOfWeek: [
'string'
]
recurrenceType: 'Weekly'
}
属性值
Microsoft.AlertsManagement/actionRules
| Name | Description | Value |
|---|---|---|
| 位置 | 资源所在的地理位置 | string (必需) |
| name | 资源名称 | string (必需) |
| properties | 警报处理规则属性。 | AlertProcessingRuleProperties |
| tags | 资源标记 | 标记名称和值的字典。 请参阅模板 中的 标记 |
Action
| Name | Description | Value |
|---|---|---|
| actionType | 对于 类型 AddActionGroups,设置为“AddActionGroups”。 对于 类型 RemoveAllActionGroups,设置为“RemoveAllActionGroups”。 | 'AddActionGroups' “RemoveAllActionGroups”(必需) |
AddActionGroups
| Name | Description | Value |
|---|---|---|
| actionGroupIds | 要添加到警报处理规则的操作组 ID 列表。 | string[] (必需) |
| actionType | 应应用的操作。 | “AddActionGroups”(必需) |
AlertProcessingRuleProperties
| Name | Description | Value |
|---|---|---|
| actions | 要应用的操作。 | Action[](必填) |
| conditions | 将筛选警报的条件。 | Condition[] |
| description | 需要执行的行动。警报处理规则的描述。 | 字符串 |
| enabled | 指示给定的警报处理规则是启用或禁用的。 | bool |
| schedule | 警报处理规则的计划。 | Schedule |
| scopes | 将应用警报处理规则的范围。 | string[] (必需) |
Condition
| Name | Description | Value |
|---|---|---|
| 字段 | 给定条件的字段。 | 'AlertContext' 'AlertRuleId' 'AlertRuleName' 'Description' 'MonitorCondition' 'MonitorService' 'Severity' 'SignalType' 'TargetResource' 'TargetResourceGroup' 'TargetResourceType' |
| 操作员 | 给定条件的运算符。 | 'Contains' 'DoesNotContain' 'Equals' 'NotEquals' |
| values | 要匹配给定条件的值列表。 | string[] |
DailyRecurrence
| Name | Description | Value |
|---|---|---|
| recurrenceType | 指定何时应应用重复周期。 | “每日”(必填) |
MonthlyRecurrence
| Name | Description | Value |
|---|---|---|
| daysOfMonth | 指定每月重复模式的值。 | int[] (必填) |
| recurrenceType | 指定何时应应用重复周期。 | “每月”(必填) |
Recurrence
| Name | Description | Value |
|---|---|---|
| endTime | 重复周期的结束时间。 | 字符串 |
| recurrenceType | 将类型 DailyRecurrence 设置为“每日”。 将类型 MonthlyRecurrence 设置为“Monthly”。 将类型 WeeklyRecurrence 设置为“每周”。 | 'Daily' 'Monthly' “每周”(必填) |
| startTime | 重复周期的开始时间。 | 字符串 |
RemoveAllActionGroups
| Name | Description | Value |
|---|---|---|
| actionType | 应应用的操作。 | “RemoveAllActionGroups”(必需) |
Schedule
| Name | Description | Value |
|---|---|---|
| effectiveFrom | 计划从时间起生效。 在没有时区后缀的情况下采用 ISO-8601 格式的 Date-Time。 | string Constraints: 图案 = ^(?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))$ |
| effectiveUntil | 计划有效,直到时间。 在没有时区后缀的情况下采用 ISO-8601 格式的 Date-Time。 | string Constraints: 图案 = ^(?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))$ |
| recurrences | 重复周期列表。 | Recurrence[] |
| timeZone | 计划时区。 | 字符串 |
TrackedResourceTags
| Name | Description | Value |
|---|
WeeklyRecurrence
| Name | Description | Value |
|---|---|---|
| daysOfWeek | 指定每周重复模式的值。 | 包含任一项的字符串数组: 'Friday' 'Monday' 'Saturday' 'Sunday' 'Thursday' 'Tuesday' “星期三”(必填) |
| recurrenceType | 指定何时应应用重复周期。 | “每周”(必填) |
ARM 模板资源定义
可以使用目标操作部署 actionRules 资源类型:
用法示例
Azure 快速入门模板
以下Azure快速启动模板部署了这种资源类型。
| Template | Description |
|---|---|
|
设置备份警报通知,使用Azure Monitor |
该模板允许您通过部署警报处理规则和动作组,为您的恢复服务保险库设置电子邮件通知Azure Monitor |
资源格式
若要创建 Microsoft.AlertsManagement/actionRules 资源,请将以下 JSON 添加到模板。
{
"type": "Microsoft.AlertsManagement/actionRules",
"apiVersion": "2021-08-08",
"name": "string",
"location": "string",
"properties": {
"actions": [ {
"actionType": "string"
// For remaining properties, see Action objects
} ],
"conditions": [
{
"field": "string",
"operator": "string",
"values": [ "string" ]
}
],
"description": "string",
"enabled": "bool",
"schedule": {
"effectiveFrom": "string",
"effectiveUntil": "string",
"recurrences": [ {
"endTime": "string",
"startTime": "string",
"recurrenceType": "string"
// For remaining properties, see Recurrence objects
} ],
"timeZone": "string"
},
"scopes": [ "string" ]
},
"tags": {
"{customized property}": "string"
}
}
作对象
设置 actionType 属性以指定对象的类型。
对于 AddActionGroups,请使用:
{
"actionGroupIds": [ "string" ],
"actionType": "AddActionGroups"
}
对于 RemoveAllActionGroups,请使用:
{
"actionType": "RemoveAllActionGroups"
}
重复对象
设置 recurrenceType 属性以指定对象的类型。
对于 日常,请使用:
{
"recurrenceType": "Daily"
}
对于 每月,请使用:
{
"daysOfMonth": [ "int" ],
"recurrenceType": "Monthly"
}
对于 每周,请使用:
{
"daysOfWeek": [ "string" ],
"recurrenceType": "Weekly"
}
属性值
Microsoft.AlertsManagement/actionRules
| Name | Description | Value |
|---|---|---|
| apiVersion | API 版本 | '2021-08-08' |
| 位置 | 资源所在的地理位置 | string (必需) |
| name | 资源名称 | string (必需) |
| properties | 警报处理规则属性。 | AlertProcessingRuleProperties |
| tags | 资源标记 | 标记名称和值的字典。 请参阅模板 中的 标记 |
| 类型 | 资源类型 | 'Microsoft.AlertsManagement/actionRules' |
Action
| Name | Description | Value |
|---|---|---|
| actionType | 对于 类型 AddActionGroups,设置为“AddActionGroups”。 对于 类型 RemoveAllActionGroups,设置为“RemoveAllActionGroups”。 | 'AddActionGroups' “RemoveAllActionGroups”(必需) |
AddActionGroups
| Name | Description | Value |
|---|---|---|
| actionGroupIds | 要添加到警报处理规则的操作组 ID 列表。 | string[] (必需) |
| actionType | 应应用的操作。 | “AddActionGroups”(必需) |
AlertProcessingRuleProperties
| Name | Description | Value |
|---|---|---|
| actions | 要应用的操作。 | Action[](必填) |
| conditions | 将筛选警报的条件。 | Condition[] |
| description | 需要执行的行动。警报处理规则的描述。 | 字符串 |
| enabled | 指示给定的警报处理规则是启用或禁用的。 | bool |
| schedule | 警报处理规则的计划。 | Schedule |
| scopes | 将应用警报处理规则的范围。 | string[] (必需) |
Condition
| Name | Description | Value |
|---|---|---|
| 字段 | 给定条件的字段。 | 'AlertContext' 'AlertRuleId' 'AlertRuleName' 'Description' 'MonitorCondition' 'MonitorService' 'Severity' 'SignalType' 'TargetResource' 'TargetResourceGroup' 'TargetResourceType' |
| 操作员 | 给定条件的运算符。 | 'Contains' 'DoesNotContain' 'Equals' 'NotEquals' |
| values | 要匹配给定条件的值列表。 | string[] |
DailyRecurrence
| Name | Description | Value |
|---|---|---|
| recurrenceType | 指定何时应应用重复周期。 | “每日”(必填) |
MonthlyRecurrence
| Name | Description | Value |
|---|---|---|
| daysOfMonth | 指定每月重复模式的值。 | int[] (必填) |
| recurrenceType | 指定何时应应用重复周期。 | “每月”(必填) |
Recurrence
| Name | Description | Value |
|---|---|---|
| endTime | 重复周期的结束时间。 | 字符串 |
| recurrenceType | 将类型 DailyRecurrence 设置为“每日”。 将类型 MonthlyRecurrence 设置为“Monthly”。 将类型 WeeklyRecurrence 设置为“每周”。 | 'Daily' 'Monthly' “每周”(必填) |
| startTime | 重复周期的开始时间。 | 字符串 |
RemoveAllActionGroups
| Name | Description | Value |
|---|---|---|
| actionType | 应应用的操作。 | “RemoveAllActionGroups”(必需) |
Schedule
| Name | Description | Value |
|---|---|---|
| effectiveFrom | 计划从时间起生效。 在没有时区后缀的情况下采用 ISO-8601 格式的 Date-Time。 | string Constraints: 图案 = ^(?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))$ |
| effectiveUntil | 计划有效,直到时间。 在没有时区后缀的情况下采用 ISO-8601 格式的 Date-Time。 | string Constraints: 图案 = ^(?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))$ |
| recurrences | 重复周期列表。 | Recurrence[] |
| timeZone | 计划时区。 | 字符串 |
TrackedResourceTags
| Name | Description | Value |
|---|
WeeklyRecurrence
| Name | Description | Value |
|---|---|---|
| daysOfWeek | 指定每周重复模式的值。 | 包含任一项的字符串数组: 'Friday' 'Monday' 'Saturday' 'Sunday' 'Thursday' 'Tuesday' “星期三”(必填) |
| recurrenceType | 指定何时应应用重复周期。 | “每周”(必填) |
Terraform (AzAPI 提供程序)资源定义
可以使用目标操作部署 actionRules 资源类型:
- 资源组 关于每个API版本中变更属性的列表,请参见 更改日志。
用法示例
Terraform 示例
部署应用作组的警报处理规则的基本示例。
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" "actionRule" {
type = "Microsoft.AlertsManagement/actionRules@2021-08-08"
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = "global"
body = {
properties = {
actions = [
{
actionType = "RemoveAllActionGroups"
},
]
description = ""
enabled = true
scopes = [
azapi_resource.resourceGroup.id,
]
}
}
schema_validation_enabled = false
response_export_values = ["*"]
}
资源格式
若要创建 Microsoft.AlertsManagement/actionRules 资源,请将以下 Terraform 添加到模板。
resource "azapi_resource" "symbolicname" {
type = "Microsoft.AlertsManagement/actionRules@2021-08-08"
name = "string"
parent_id = "string"
location = "string"
tags = {
{customized property} = "string"
}
body = {
properties = {
actions = [
{
actionType = "string"
// For remaining properties, see Action objects
}
]
conditions = [
{
field = "string"
operator = "string"
values = [
"string"
]
}
]
description = "string"
enabled = bool
schedule = {
effectiveFrom = "string"
effectiveUntil = "string"
recurrences = [
{
endTime = "string"
startTime = "string"
recurrenceType = "string"
// For remaining properties, see Recurrence objects
}
]
timeZone = "string"
}
scopes = [
"string"
]
}
}
}
作对象
设置 actionType 属性以指定对象的类型。
对于 AddActionGroups,请使用:
{
actionGroupIds = [
"string"
]
actionType = "AddActionGroups"
}
对于 RemoveAllActionGroups,请使用:
{
actionType = "RemoveAllActionGroups"
}
重复对象
设置 recurrenceType 属性以指定对象的类型。
对于 日常,请使用:
{
recurrenceType = "Daily"
}
对于 每月,请使用:
{
daysOfMonth = [
int
]
recurrenceType = "Monthly"
}
对于 每周,请使用:
{
daysOfWeek = [
"string"
]
recurrenceType = "Weekly"
}
属性值
Microsoft.AlertsManagement/actionRules
| Name | Description | Value |
|---|---|---|
| 位置 | 资源所在的地理位置 | string (必需) |
| name | 资源名称 | string (必需) |
| properties | 警报处理规则属性。 | AlertProcessingRuleProperties |
| tags | 资源标记 | 标记名称和值的字典。 |
| 类型 | 资源类型 | "Microsoft.AlertsManagement/actionRules@2021-08-08" |
Action
| Name | Description | Value |
|---|---|---|
| actionType | 对于 类型 AddActionGroups,设置为“AddActionGroups”。 对于 类型 RemoveAllActionGroups,设置为“RemoveAllActionGroups”。 | 'AddActionGroups' “RemoveAllActionGroups”(必需) |
AddActionGroups
| Name | Description | Value |
|---|---|---|
| actionGroupIds | 要添加到警报处理规则的操作组 ID 列表。 | string[] (必需) |
| actionType | 应应用的操作。 | “AddActionGroups”(必需) |
AlertProcessingRuleProperties
| Name | Description | Value |
|---|---|---|
| actions | 要应用的操作。 | Action[](必填) |
| conditions | 将筛选警报的条件。 | Condition[] |
| description | 需要执行的行动。警报处理规则的描述。 | 字符串 |
| enabled | 指示给定的警报处理规则是启用或禁用的。 | bool |
| schedule | 警报处理规则的计划。 | Schedule |
| scopes | 将应用警报处理规则的范围。 | string[] (必需) |
Condition
| Name | Description | Value |
|---|---|---|
| 字段 | 给定条件的字段。 | 'AlertContext' 'AlertRuleId' 'AlertRuleName' 'Description' 'MonitorCondition' 'MonitorService' 'Severity' 'SignalType' 'TargetResource' 'TargetResourceGroup' 'TargetResourceType' |
| 操作员 | 给定条件的运算符。 | 'Contains' 'DoesNotContain' 'Equals' 'NotEquals' |
| values | 要匹配给定条件的值列表。 | string[] |
DailyRecurrence
| Name | Description | Value |
|---|---|---|
| recurrenceType | 指定何时应应用重复周期。 | “每日”(必填) |
MonthlyRecurrence
| Name | Description | Value |
|---|---|---|
| daysOfMonth | 指定每月重复模式的值。 | int[] (必填) |
| recurrenceType | 指定何时应应用重复周期。 | “每月”(必填) |
Recurrence
| Name | Description | Value |
|---|---|---|
| endTime | 重复周期的结束时间。 | 字符串 |
| recurrenceType | 将类型 DailyRecurrence 设置为“每日”。 将类型 MonthlyRecurrence 设置为“Monthly”。 将类型 WeeklyRecurrence 设置为“每周”。 | 'Daily' 'Monthly' “每周”(必填) |
| startTime | 重复周期的开始时间。 | 字符串 |
RemoveAllActionGroups
| Name | Description | Value |
|---|---|---|
| actionType | 应应用的操作。 | “RemoveAllActionGroups”(必需) |
Schedule
| Name | Description | Value |
|---|---|---|
| effectiveFrom | 计划从时间起生效。 在没有时区后缀的情况下采用 ISO-8601 格式的 Date-Time。 | string Constraints: 图案 = ^(?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))$ |
| effectiveUntil | 计划有效,直到时间。 在没有时区后缀的情况下采用 ISO-8601 格式的 Date-Time。 | string Constraints: 图案 = ^(?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))$ |
| recurrences | 重复周期列表。 | Recurrence[] |
| timeZone | 计划时区。 | 字符串 |
TrackedResourceTags
| Name | Description | Value |
|---|
WeeklyRecurrence
| Name | Description | Value |
|---|---|---|
| daysOfWeek | 指定每周重复模式的值。 | 包含任一项的字符串数组: 'Friday' 'Monday' 'Saturday' 'Sunday' 'Thursday' 'Tuesday' “星期三”(必填) |
| recurrenceType | 指定何时应应用重复周期。 | “每周”(必填) |