Forum Discussion

Bilal_Achahbar's avatar
Bilal_Achahbar
Copper Contributor
Dec 03, 2018
Solved

Create OMS Alert throug ARM template

Hi  all I am trying to create an oms workspace with alerts attached to it through ARM templates. I already created an OMS workspace and for the alert part I followed the following tutorial. After so...
  • Hi,

    The blog post you reference is old as there are changes in the API. Log Analytics alerts no longer use their own actions rather they reference Action Group. So you first you have to have Action Group to reference. You've found the link for creating Action Group via ARM template. You've also find the template for creating Log Analytics alerts. You still have to create saved search, schedule and action resources. The main difference in the action you have to reference the Action Group. The extending alerts to Azure means that if you had created previously alerts that were using the api referenced in the blog post you've provided will be converted to using Action Group automatically. In short the only differences are the API version is increased and this part of action resources:

     "EmailNotification": {
                "Recipients": [
                    "[parameters('EmailRecipients')]"
                ],
                "Subject": "[parameters('DisplayNameOfSearch')]"
            }

    cannot be used but instead you have to references action group.

    "AzNsNotification": {
            "GroupIds": "[variables('MyAlert').AzNsNotification.GroupIds]",
            "CustomEmailSubject": "[variables('MyAlert').AzNsNotification.CustomEmailSubject]",
            "CustomWebhookPayload": "[variables('MyAlert').AzNsNotification.CustomWebhookPayload]"
            }

    CustomEmailSubject and CustomWebhookPayload are not mandatory parameters and if they are not used you can skip them. You can also see GroupIds is actually array so you can reference multiple resource groups if needed. Look at the full sample to help you understand better:

    https://docs.microsoft.com/en-us/azure/azure-monitor/insights/solutions-resources-searches-alerts#sample

     

Resources