azure-data-factoryazure-diagnostics

Is there any Terraform code or ARM Template code available for enabling diagnostic settings in data factory


I am able to enable diagnostic settings manually in the portal,If i want to automatically create diagnostic settings for data factory through code, is there any terraform code or ARM template code available to do this

Thanks in advance


Solution

  • I tried with this ARM template and successfully enabled diagnostics settings.

    {
    "$schema": "https://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {},
    "variables": {},
    "resources": [
      {
        "apiVersion": "2017-05-10",
        "name": "Deploy_DataFactoryDiagSettings",
        "type": "Microsoft.Resources/deployments",
        "resourceGroup": "YourResourceGroupName",
        "properties": {
          "mode": "Incremental",
          "template": {
            "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
            "contentVersion": "1.0.0.0",
            "parameters": {},
            "variables": {},
            "resources": [
              {
                "type": "microsoft.datafactory/factories/providers/diagnosticsettings",
                "name": "{YourADFresourceName}/Microsoft.Insights/ADFDiagSetting",
                "apiVersion": "2017-05-01-preview",
                "properties": {
                  "name": "ADFDiagSetting",
                  "storageAccountId": null,
                  "eventHubAuthorizationRuleId": null,
                  "eventHubName": null,
                  "workspaceId": "/subscriptions/{YourSubscriptionID}/resourceGroups/{YourResourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceID}",
                  "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
                      }
                    }
                  ]
                }
              }
            ],
            "outputs": {}
          },
          "parameters": {}
        }
      }
    ],
    "outputs": {}
    

    }

    enter image description here

    enter image description here