共用方式為


Azure 監視器中的動作群組適用的 Resource Manager 範本範例

本文說明在 Azure 監視器中建立動作群組時適用的範例 Azure Resource Manager 範本。 每個範例都包含範本檔案和參數檔案,且附有要提供給範本的範例值。

注意

如需 Azure 監視器的可用範例清單,以及在 Azure 訂用帳戶中的部署指引,請參閱 Azure Resource Manager 範例

建立動作群組

下列範例會建立動作群組。

範本檔案

@description('Unique name within the resource group for the Action group.')
param actionGroupName string

@description('Short name up to 12 characters for the Action group.')
param actionGroupShortName string

resource actionGroup 'Microsoft.Insights/actionGroups@2021-09-01' = {
  name: actionGroupName
  location: 'Global'
  properties: {
    groupShortName: actionGroupShortName
    enabled: true
    smsReceivers: [
      {
        name: 'contosoSMS'
        countryCode: '1'
        phoneNumber: '5555551212'
      }
      {
        name: 'contosoSMS2'
        countryCode: '1'
        phoneNumber: '5555552121'
      }
    ]
    emailReceivers: [
      {
        name: 'contosoEmail'
        emailAddress: 'devops@contoso.com'
        useCommonAlertSchema: true
      }
      {
        name: 'contosoEmail2'
        emailAddress: 'devops2@contoso.com'
        useCommonAlertSchema: true
      }
    ]
    webhookReceivers: [
      {
        name: 'contosoHook'
        serviceUri: 'http://requestb.in/1bq62iu1'
        useCommonAlertSchema: true
      }
      {
        name: 'contosoHook2'
        serviceUri: 'http://requestb.in/1bq62iu2'
        useCommonAlertSchema: true
      }
    ]
  }
}

output actionGroupId string = actionGroup.id

參數檔案

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
      "actionGroupName": {
        "value": "My Action Group"
      },
      "actionGroupShortName": {
        "value": "mygroup"
      }
  }
}

下一步