如何引用已经在ARM模板中创建的资源?

时间:2018-10-08 15:41:29

标签: json azure azure-cosmosdb azure-resource-manager

我正在尝试使用arm模板为我的cosmosdb帐户创建警报,因为cosmosdb已创建,所以我无法使用dependsOn来引用rosurce。

"resources": [
  {

          "type": "microsoft.insights/alertrules",
          "name": "[parameters('alertrules_alert_name')]",
          "apiVersion": "2014-04-01",
          "location": "southcentralus",

          "scale": null,
          "properties": {
              "name": "[parameters('alertrules_alert_name')]",
              "description": null,
              "isEnabled": true,
              "condition": {
                  "odata.type": "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition",
                  "dataSource": {
                      "odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
                      "resourceUri": "[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('databaseAccounts_cosmosaccount_name_1'))]",
                      "metricNamespace": null,
                      "metricName": "Http 401"
                  },
                  "operator": "GreaterThan",
                  "threshold": 1,
                  "windowSize": "PT30M"
              },
              "action": null
          }
  }
],
    "outputs": {}
}

1 个答案:

答案 0 :(得分:0)

在创建 NEW Cosmos DB资源时,请查阅以下文档以通过ARM模板启用(经典)警报诊断设置。< / p>

1) Create a classic metric alert with a Resource Manager template 2) Automatically enable Diagnostic Settings at resource creation using a Resource Manager template 3) Azure Cosmos DB diagnostic logging

请向上投票以使用现有的ARM Templete功能条目,或创建一个特定于您的用例的新用户语音条目:Azure Cosmos DB User Voice