Public/Core/monitoring/New-CmAzCoreMonitor.Monitoring.json

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "ActionGroups": {
            "type": "array",
            "defaultValue": [
            ]
        },
        "ServiceHealthAlertName": {
            "type": "string"
        }
    },
    "resources": [
        {
            "type": "Microsoft.Insights/actionGroups",
            "apiVersion": "2019-03-01",
            "name": "[parameters('ActionGroups')[copyIndex()].name]",
            "location": "Global",
            "tags": {
                "cm-service": "[concat('core.monitoring.actiongroup.priority', add(copyIndex(), 1), '.default')]"
            },
            "properties": {
                "groupShortName": "[parameters('ActionGroups')[copyIndex('ActionGroupCopy')].shortName]",
                "enabled": true,
                "armRoleReceivers": "[parameters('ActionGroups')[copyIndex('ActionGroupCopy')].armRoles]",
                "automationRunbookReceivers": "[parameters('actionGroups')[copyIndex('ActionGroupCopy')].runbooks]",
                "azureAppPushReceivers": "[parameters('ActionGroups')[copyIndex('ActionGroupCopy')].notifications]",
                "azureFunctionReceivers": "[parameters('ActionGroups')[copyIndex('ActionGroupCopy')].functions]",
                "emailReceivers": "[parameters('ActionGroups')[copyIndex('ActionGroupCopy')].emails]",
                "itsmReceivers": "[parameters('ActionGroups')[copyIndex('ActionGroupCopy')].itsm]",
                "logicAppReceivers": "[parameters('ActionGroups')[copyIndex('ActionGroupCopy')].logicApps]",
                "smsReceivers": "[parameters('ActionGroups')[copyIndex('ActionGroupCopy')].sms]",
                "voiceReceivers": "[parameters('ActionGroups')[copyIndex('ActionGroupCopy')].voice]",
                "webhookReceivers": "[parameters('ActionGroups')[copyIndex('ActionGroupCopy')].webhooks]"
            },
            "copy": {
                "name": "ActionGroupCopy",
                "count": "[length(parameters('ActionGroups'))]"
            }
        },
        {
            "type": "microsoft.insights/activityLogAlerts",
            "apiVersion": "2017-04-01",
            "name": "[parameters('serviceHealthAlertName')]",
            "location": "Global",
            "dependsOn": [
                "[resourceId('microsoft.insights/actionGroups', parameters('ActionGroups')[0].name)]"
            ],
            "properties": {
                "scopes": [
                    "[subscription().Id]"
                ],
                "condition": {
                    "allOf": [
                        {
                            "field": "category",
                            "equals": "ServiceHealth"
                        },
                        {
                            "field": "properties.impactedServices[*].ImpactedRegions[*].RegionName",
                            "equals": null,
                            "containsAny": [
                                "[resourceGroup().location]"
                            ]
                        }
                    ]
                },
                "actions": {
                    "actionGroups": [
                        {
                            "actionGroupId": "[resourceId('microsoft.insights/actionGroups', parameters('ActionGroups')[0].name)]",
                            "webhookProperties": {}
                        }
                    ]
                },
                "enabled": true
            }
        }
    ]
}