当我部署我的 Azure ARM 模板时,它会创建一个存储,而不是警报

When i deploy my Azure ARM Template it creates a storage, not an alert

我为警报创建了一个 Azure 模板,因为我想同时上传脚本 (.json) 和新的微服务。但是如果我部署这个 .json 文件,它会创建一个新的存储,而不是警报。我使用了 Powershell 命令 New-AzureRmResourceGroupDeployment -Name ExampleDeployment -ResourceGroupName ExampleResourceGroup -TemplateFile c:\MyTemplates\storage.json -storageAccountType Standard_GRS。在我的模板中,我需要定义参数 kind,它只能接受 StorageBlobstorage 的值,但我不想要这两个。那么我如何使用脚本 .json 文件来创建警报并且是否有人有模板,因为 MS 没有提供正确的模板。

编辑:这是 .json 文件:

{
"$schema":
"http://schema.management.azure.com/schemas/2015-01- 
01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
  "name": "[concat('storage', uniqueString(resourceGroup().id))]",
  "type": "Microsoft.Storage/storageAccounts",
  "apiVersion": "2016-01-01",
  "sku": {
    "name": "Standard_LRS"
  },
  "kind": "Storage",
  "id":
    "/subscriptions/subscriptionID/resourceGroups/resourceGroupName/providers/Microsoft.Storage/storageAccounts/storageName",
  "location": "westeurope",
  "properties": {
    "name": "tryAgain",
    "description": null,
    "isEnabled": true,
    "condition": {
      "$type":
        "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.ThresholdRuleCondition, Microsoft.WindowsAzure.Management.Mon.Client",
      "odata.type":
        "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition",
      "dataSource": {
        "$type":
          "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.RuleMetricDataSource, Microsoft.WindowsAzure.Management.Mon.Client",
        "odata.type":
          "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
        "resourceUri":
          "/subscriptions/subscriptionID/resourcegroups/resourceGroupName/providers/microsoft.web/sites/name",
        "resourceLocation": null,
        "metricNamespace": null,
        "metricName": "AverageMemoryWorkingSet",
        "legacyResourceId": null
      },
      "operator": "GreaterThanOrEqual",
      "threshold": 120000000,
      "windowSize": "PT10M",
      "timeAggregation": "Average"
    },
    "actions": [
      {
        "$type":
          "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.RuleWebhookAction, Microsoft.WindowsAzure.Management.Mon.Client",
        "odata.type":
          "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction",
        "serviceUri":
          "Logic-app URL",
        "properties": {
          "$type":
            "Microsoft.WindowsAzure.Management.Common.Storage.CasePreservedDictionary`1[[System.String, mscorlib]], Microsoft.WindowsAzure.Management.Common.Storage",
          "logicAppResourceId":
            "/subscriptions/subscriptionID/resourceGroups/Default-Storage-WestEurope/providers/Microsoft.Logic/workflows/Microsoft-Teams-Notifier"
        }
      }
    ]
  }
}
]
}

有关通过 Azure 资源管理器模板创建指标警报的信息,请参阅以下参考资料。如果你想创建一个单独的 ARM 模板来创建一个存储帐户,然后一个指标警报来监视创建的存储帐户,你应该确保你有一个 dependsOn,这样警报规则只在存储帐户之后创建。以下文档引用了较新的指标警报,而不是经典的指标警报。

https://docs.microsoft.com/en-us/azure/monitoring-and-diagnostics/monitoring-create-metric-alerts-with-templates