使用手臂模板在Azure数据工厂中启用诊断

时间:2019-09-22 09:01:31

标签: azure azure-data-factory arm-template azure-diagnostics

我想使用ARM模板启用Azure Datafactory的诊断。

我找到了这个post,然后尝试测试我的代码:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": { },
  "variables": {},
  "resources": [
 {
        "name": "test-adf2-we",
        "type": "Microsoft.DataFactory/factories",
         "apiVersion": "2018-06-01",
         "location": "West Europe",
         "identity": {
           "type": "SystemAssigned"
         }
 },
{
      "name": "test-ala-we",
      "type": "Microsoft.OperationalInsights/workspaces",
      "apiVersion": "2015-11-01-preview",
      "location": "West Europe"
    },
    {
      "type": "microsoft.datafactory/factories/providers/diagnosticsettings",
      "name": "[concat('test-adf2-we','/Microsoft.Insights/diagnostics')]",
      "location": "West Europe",
      "apiVersion": "2017-05-01-preview",
      "properties": {
        "name": "diagnostics",
        "storageAccountId": null,
        "eventHubAuthorizationRuleId": null,
        "eventHubName": null,
        "workspaceId": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/test-arm/providers/Microsoft.OperationalInsights/test-ala-we"
        "logs": [
          {
            "category": "PipelineRuns",
            "enabled": true,
            "retentionPolicy": {
              "enabled": false,
              "days": 0
            }
          },
          {
            "category": "TriggerRuns",
            "enabled": true,
            "retentionPolicy": {
              "enabled": false,
              "days": 0
            }
          },
          {
            "category": "ActivityRuns",
            "enabled": true,
            "retentionPolicy": {
              "enabled": false,
              "days": 0
            }
          }
        ],
        "metrics": [
          {
            "category": "AllMetrics",
            "timeGrain": "PT1M",
            "enabled": true,
            "retentionPolicy": {
              "enabled": false,
              "days": 0
            }
          }
        ]
      }
   }
}

运行此代码后。我收到此错误:

Template deployment returned the following errors:
 Resource microsoft.datafactory/factories/providers/diagnosticsettings 'test-adf2-we/Microsoft.Insights/diagnostics' failed with message '{
  "code": "BadRequest",
   "message": "\"Resource type 'microsoft.operationalinsights/test-ala-we' is invalid for property 'properties.workspaceId'. Expected types are 'microsoft.operationalinsights/workspaces'\""
 }'

您能帮我解决这个问题吗?

2 个答案:

答案 0 :(得分:1)

您的resourceId错误,请像这样修复它:

"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/test-arm/providers/Microsoft.OperationalInsights/workspaces/test-ala-we"

您遗漏了workspaces(这就是错误告诉您的内容)。

答案 1 :(得分:1)

请务必添加

"logAnalyticsDestinationType": "Dedicated"

否则,Log Analytics将写入默认AzureDiagnostic表。使用Log Analytics时,此值为Microsoft Best Practice,因为AzureDiagnostics表中的500列存在硬停。一旦达到500列的阈值,记录就不会插入表中。