1

{
   "mode":"All",
   "policyRule":{
      "if":{
         "allOf":[
            {
               "field":"type",
               "equals":"Microsoft.Insights/metricalerts"
            },
            {
               "field":"Microsoft.Insights/metricalerts/enabled",
               "equals":"true"
            }
         ]
      },
      "then":{
         "effect":"deployIfNotExists",
         "details":{
            "type":"microsoft.insights/actiongroups",
            "deploymentScope":"subscription",
            "existenceScope":"subscription",
            "existenceCondition":{
               "allOf":[
                  {
                     "field":"Microsoft.Insights/metricalerts/actions[*]",
                     "less":"1"
                  }
               ]
            },
            "roleDefinitionIds":[
               "/providers/microsoft.authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
            ],
            "deployment":{
               "location":"centralus",
               "properties":{
                  "mode":"incremental",
                  "parameters":{
                     "actionGroupName":{
                        "value":"ActionGroup1"
                     },
                     "actionGroupShortName":{
                        "value":"AG1"
                     }
                  },
                  "template":{
                     "$schema":"http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
                     "contentVersion":"1.0.0.0",
                     "parameters":{
                        "actionGroupName":{
                           "type":"string",
                           "metadata":{
                              "description":"Unique name (within the Resource Group) for the Action group."
                           }
                        },
                        "actionGroupShortName":{
                           "type":"string",
                           "metadata":{
                              "description":"Short name (maximum 12 characters) for the Action group."
                           }
                        }
                     },
                     "resources":[
                        {
                           "name":"[parameters('actionGroupName')]",
                           "type":"microsoft.insights/actionGroups",
                           "apiVersion":"2018-09-01",
                           "location":"global",
                           "properties":{
                              "groupShortName":"[parameters('actionGroupShortName')]",
                              "enabled":true,
                              "emailReceivers":[
                                 {
                                    "name":"TestMail",
                                    "emailAddress":"sachin.kalia15@gmail.com"
                                 }
                              ],
                              "smsReceivers":[
                                 {
                                    "name":"TestSMS",
                                    "countryCode":"91",
                                    "phoneNumber":"99116"
                                 }
                              ],
                              "armRoleReceivers":[
                                 {
                                    "name":"TestCont",
                                    "roleId":"b24988ac-6180-42a0-ab88-20f7382dd24c"
                                 }
                              ]
                           }
                        }
                     ]
                  }
               }
            }
         }
      }
   },
   "parameters":{

   }
}

我正在创建一个策略并成功创建它,尽管在 azure 门户中使用修复任务对其进行重新修复时,它失败并提示我出现以下错误

在此处输入图像描述

找不到资源组“”下的资源“microsoft.insights/actiongroups/HmActionGroup”。这是用于策略的 arm 模板中的一种资源格式。就我而言,我已将位置提供为“全球”

在此处输入图像描述

任何帮助将不胜感激

4

1 回答 1

0

要在订阅级别部署,您需要在模板中使用订阅部署架构:

"$schema":"https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#"
于 2019-10-10T19:21:00.893 回答