找不到资源组null下的资源“ microsoft.insights / actiongroups / HmActionGroup”

时间:2019-09-23 14:12:29

标签: azure azure-web-sites azure-powershell azure-policy

{
   "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门户中的“修复”任务进行修复时,该策略失败并提示我以下错误

https://structuremap.github.io/registration/registry-dsl/

未找到资源组“”下的资源“ microsoft.insights / actiongroups / HmActionGroup”。 这是用于策略的手臂模板中的资源格式。就我而言,我已将位置设置为“全球”

enter image description here

任何帮助将不胜感激

1 个答案:

答案 0 :(得分:0)

要在订阅级别进行部署,您需要在模板中使用订阅部署模式:

"$schema":"https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#"