Azure Data Factory how to deploy Alerts & Metrics to other environments with DevOps

Viewed 455

We have a Azure datafactory fully integrated with DevOps. Every change I make to the datafactory is deployed to all environments (OTAP), except alerts & metrics. I cannot find anything on how to deploy these to the other environments. Is this possible at all?

2 Answers

Is this possible at all?'

Quick answer is NO so far. I contacted Microsoft ADF team and got below response:

Azure Data Factory utilizes Azure Resource Manager templates to store the configuration of your various ADF entities. Entities on Alerts & Metrics does not get exported in the ARM template, so Alerts & Metrics won’t be integrated using DevOps.

I did 2 verifications:

1.Check ARM template supported entities in ADF, Alerts & Metrics doesn't exist.

2.Try to export ARM template in the ADF UI but still no Alerts & Metrics

enter image description here

Really understand you would like to integrate all elements in Data Factory including Alerts & Metrics with DevOps. I suggest you submitting feedback here to push improvements of ADF, any voice is welcome.

There is a way to work around this one. ADF alert is a "Microsoft.Insights/metricalerts" resource that you can deploy using ARM deployment operation from Azure Devops. You can try to create an alert in ADF and then go to Portal, search for: Monitor > Alert > Alert Rule, and find the Alert you created in ADF. In my case there is an Alert called Test

Here is the ARM template exported from the alert

{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
    "metricalerts_Alert_name": {
        "defaultValue": "Alert",
        "type": "String"
    },
    "factories_test_externalid": {
        "defaultValue": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/yyyyy/providers/Microsoft.DataFactory/factories/test",
        "type": "String"
    },
    "actionGroups_actiongroup1_externalid": {
        "defaultValue": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/yyyyy/providers/microsoft.insights/actionGroups/actiongroup1",
        "type": "String"
    }
},
"variables": {},
"resources": [
    {
        "type": "Microsoft.Insights/metricalerts",
        "apiVersion": "2018-03-01",
        "name": "[parameters('metricalerts_Alert_name')]",
        "location": "global",
        "tags": {
            "CreatedTimeUtc": "2022-09-13T05:28:46.0663823Z"
        },
        "properties": {
            "severity": 0,
            "enabled": true,
            "scopes": [
                "[parameters('factories_test_externalid')]"
            ],
            "evaluationFrequency": "PT1M",
            "windowSize": "PT15M",
            "criteria": {
                "allOf": [
                    {
                        "threshold": 1,
                        "name": "PipelineFailedRuns",
                        "metricNamespace": "Microsoft.DataFactory/factories",
                        "metricName": "PipelineFailedRuns",
                        "dimensions": [
                            {
                                "name": "Name",
                                "operator": "Include",
                                "values": [
                                    "pipeline2"
                                ]
                            },
                            {
                                "name": "FailureType",
                                "operator": "Include",
                                "values": [
                                    "UserError",
                                    "SystemError",
                                    "BadGateway"
                                ]
                            }
                        ],
                        "operator": "GreaterThanOrEqual",
                        "timeAggregation": "Total",
                        "criterionType": "StaticThresholdCriterion"
                    }
                ],
                "odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria"
            },
            "actions": [
                {
                    "actionGroupId": "[parameters('actionGroups_actiongroup1_externalid')]",
                    "webHookProperties": {}
                }
            ]
        }
    }
]
}

For the actionGroups you can refer to

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "groupName": {
      "defaultValue": "actiongroup1",
      "type": "string"
    },
    "email_receiver_address": {
      "defaultValue": "someEmail@gmail.com",
      "type": "string"
    }
  },
  "variables": {},
  "resources": [
    {
      "type": "microsoft.insights/actionGroups",
      "apiVersion": "2019-03-01",
      "name": "[parameters('groupName')]",
      "location": "global",
      "tags": {
        "CreatedTimeUtc": "2020-10-21T07:24:08.2808723Z",
      },
      "properties": {
        "groupShortName": "test",
        "enabled": true,
        "emailReceivers": [
          {
            "name": "test email received",
            "emailAddress": "[parameters('email_receiver_address')]",
            "useCommonAlertSchema": false
          }
        ],
        "smsReceivers": [],
        "webhookReceivers": [],
        "itsmReceivers": [],
        "azureAppPushReceivers": [],
        "automationRunbookReceivers": [],
        "voiceReceivers": [],
        "logicAppReceivers": [],
        "azureFunctionReceivers": []
      }
    }
  ]
}
Related