Microsoft.AlertsManagement 動作規則

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 已驗證的模組

以下的 Azure 已驗證模組 可用於部署此資源類型。

Module Description
動作規則 動作規則的AVM資源模組

Azure 快速入門範例

以下的 Azure 快速啟動範本包含部署此資源類型的Bicep範例。

Bicep檔案 Description
使用 Azure 監視器 此範本允許您使用 Azure 監視器 為 Recovery Services 保險庫設定電子郵件通知,並部署警報處理規則與動作群組

資源格式

要建立 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
位置 資源所在的地理位置 字串 (必要)
name 資源名稱 字串 (必要)
properties 警示處理規則屬性。 AlertProcessingRuleProperties
tags 資源標籤 標記名稱和值的字典。 請參閱範本中的 標籤

Action

Name Description Value
actionType 對於 類型 AddActionGroups,設置為“AddActionGroups”。 對於 類型 RemoveAllActionGroups,設置為“RemoveAllActionGroups”。 'AddActionGroups'
“RemoveAllActionGroups”(必需)

AddActionGroups

Name Description Value
actionGroupIds 要新增至警示處理規則的動作群組標識符清單。 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 排程從時間起生效。 Date-Time ISO-8601 格式,不含時區後綴。 string

Constraints:
圖案 = ^(?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))$
effectiveUntil 排程有效直到時間為止。 Date-Time ISO-8601 格式,不含時區後綴。 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 Quickstart templates

以下的 Azure 快速起始範本部署此資源類型。

Template Description
使用 Azure 監視器

部署至Azure
此範本允許您使用 Azure 監視器 為 Recovery Services 保險庫設定電子郵件通知,並部署警報處理規則與動作群組

資源格式

若要建立 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'
位置 資源所在的地理位置 字串 (必要)
name 資源名稱 字串 (必要)
properties 警示處理規則屬性。 AlertProcessingRuleProperties
tags 資源標籤 標記名稱和值的字典。 請參閱範本中的 標籤
型別 資源類型 'Microsoft.AlertsManagement/actionRules'

Action

Name Description Value
actionType 對於 類型 AddActionGroups,設置為“AddActionGroups”。 對於 類型 RemoveAllActionGroups,設置為“RemoveAllActionGroups”。 'AddActionGroups'
“RemoveAllActionGroups”(必需)

AddActionGroups

Name Description Value
actionGroupIds 要新增至警示處理規則的動作群組標識符清單。 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 排程從時間起生效。 Date-Time ISO-8601 格式,不含時區後綴。 string

Constraints:
圖案 = ^(?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))$
effectiveUntil 排程有效直到時間為止。 Date-Time ISO-8601 格式,不含時區後綴。 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
位置 資源所在的地理位置 字串 (必要)
name 資源名稱 字串 (必要)
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 要新增至警示處理規則的動作群組標識符清單。 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 排程從時間起生效。 Date-Time ISO-8601 格式,不含時區後綴。 string

Constraints:
圖案 = ^(?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))$
effectiveUntil 排程有效直到時間為止。 Date-Time ISO-8601 格式,不含時區後綴。 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 指定何時應套用週期。 “每周”(必填)