Public/Deploy/Monitor/logAlerts/New-CmAzMonitorLogAlerts.json

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "Alerts": {
            "type": "array"
        },
        "Workspace": {
            "type": "object"
        }
    },
    "resources": [
        {
            "type": "Microsoft.Insights/scheduledQueryRules",
            "name": "[parameters('Alerts')[copyIndex('AlertCopy')].name]",
            "apiVersion": "2018-04-16",
            "location": "[parameters('Workspace').location]",
            "tags": {
                "cm-service": "[parameters('Alerts')[copyIndex('AlertCopy')].service.publish.logAlert]"
            },
            "properties": {
                "description": "[parameters('Alerts')[copyIndex('AlertCopy')].description]",
                "enabled": "[parameters('Alerts')[copyIndex('AlertCopy')].enabled]",
                "source": {
                    "query": "[parameters('Alerts')[copyIndex('AlertCopy')].query]",
                    "dataSourceId": "[parameters('Workspace').resourceId]",
                    "queryType": "ResultCount"
                },
                "schedule": {
                    "frequencyInMinutes": "[parameters('Alerts')[copyIndex('AlertCopy')].schedule.frequencyInMinutes]",
                    "timeWindowInMinutes": "[parameters('Alerts')[copyIndex('AlertCopy')].schedule.timeWindowInMinutes]"
                },
                "action": {
                    "odata.type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction",
                    "severity": "[parameters('Alerts')[copyIndex('AlertCopy')].severity]",
                    "trigger": {
                        "thresholdOperator": "[parameters('Alerts')[copyIndex('AlertCopy')].threshold.Operator]",
                        "threshold": "[parameters('Alerts')[copyIndex('AlertCopy')].threshold.value]"
                    },
                    "throttlingInMin": "[if(empty(parameters('Alerts')[copyIndex('AlertCopy')].suppress), json('null'), parameters('Alerts')[copyIndex('AlertCopy')].suppress.mins)]",
                    "throttleConsecutiveWindowCount": "[if(empty(parameters('Alerts')[copyIndex('AlertCopy')].suppress), json('null'), parameters('Alerts')[copyIndex('AlertCopy')].suppress.windows)]",
                    "aznsAction": "[parameters('Alerts')[copyIndex('AlertCopy')].aznsAction]"
                }
            },
            "copy": {
                "name": "AlertCopy",
                "count": "[length(parameters('Alerts'))]"
            }
        }
    ]
}