未经授权的 Azure Budget ARM 模板部署

Azure Budget ARM template deployment unauthorized

我正在尝试部署包含 Azure 预算的 ARM 模板。目前我正在使用 Azure CLI,但它也通过门户发生。

az deployment group create --resource-group my-rg --template-file c:\dev\arm_template.json

我想知道避免以下错误的解决方案是什么:

Deployment failed. Correlation ID: 10cfac68-3ce9-4527-bee8-df48a761f965. {

  "error": {

    "code": "401",

    "message": "Unauthorized. Request ID: 4c5ee5cb-4b71-4c8b-8965-f3b89cdd2c8a"

  }

}

我遇到了完全相同的问题,最终成为过滤器,如果过滤器设置不正确,那么预算会尝试应用于您的订阅,而不仅仅是资源组或您的目标

{
  "name": "[variables('budgetName')]",
  "type": "Microsoft.Consumption/budgets",
  "apiVersion": "2019-10-01",
  "properties": {
    "timePeriod": {
      "startDate": "2020-09-01T00:00:00Z",
      "endDate": "2028-07-01T00:00:00Z"
    },
    "timeGrain": "Monthly",
    "amount": 40,
    "currentSpend": null,
    "category": "Cost",
    "notifications": {
      "GreaterThan80": {
        "enabled": true,
        "operator": "GreaterThan",
        "threshold": 80,
        "contactEmails": [],
        "contactRoles": [],
        "contactGroups": [
          "[resourceId('Microsoft.Insights/actionGroups',variables('actionGroupName'))]"
        ]
      }
    },
    "filter": {
      "dimensions": {
        "name": "ResourceGroupName",
        "operator": "In",
        "values": [ "variables('resourceGroup')" ]
      }
    }
  }
}

我有同样的错误信息。解决方案是使用 Action Group 的完整 ID 而不仅仅是名称。

ARM 模板的通知部分示例:

"notifications": {
  "Notification1": {
    "enabled": true,
    ...
    "contactGroups": [
      "/subscriptions/xxx/resourceGroups/rg-name/providers/microsoft.insights/actionGroups/ag-name"
    ]
  }
}