Kaja
Kaja

Reputation: 3057

enabling diagnostics in an Azure datafactory using arm template

I would like to enable diagnostics for Azure Datafactory using ARM-Template.

I have found this post and then I try to test my code:

{
  "$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
            }
          }
        ]
      }
   }
}

After running this code. I get this error:

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'\""
 }'

could you help me to fix this problem?

Upvotes: 0

Views: 1290

Answers (2)

DreadedFrost
DreadedFrost

Reputation: 2978

Be sure to add

"logAnalyticsDestinationType": "Dedicated"

Otherwise Log Analytics will write to the Default AzureDiagnostic Tables. This is Microsoft Best Practice when using Log Analytics since there is a hard stop at 500 columns in the AzureDiagnostics table. Once the 500 column threshold is met records won't be inserted into the table.

Upvotes: 3

4c74356b41
4c74356b41

Reputation: 72171

your resourceId is wrong, fix it like so:

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

you left out workspaces (and this is what the error is telling you).

Upvotes: 2

Related Questions