azuresendgridsendgrid-api-v2sql-azure-alerts

Configure Alert Mail (SendGrid) in Azure using Webhook


I have an Alert configured to my app service. Consider I have server down check alert.

Whenever the alert gets triggered , I want the mail to be delivered to our mailbox with sufficient details. To achieve this, Iam directly calling the sendgrid api from Azure Alert Webhook. Im able to send mail with hardcoded data. I would want to utilise the details , Azure Alert possess, to include in the mail.

Webhook url is as follow: https://api.sendgrid.com/api/mail.send.json?api_user=********&api_key=****&to=*****&toname=*&subject=&text=#workspaceid%20#applicationid&from=**

"#workspaceid" is a parameter of json that is being sent.

However the approach does not work.

I would like to have entire json content that is initiated by Azure alerts to be included in mail body.

Alert Rule


Solution

  • The JSON payload send by the alert needs to be parsed, somehow, and sent onwards to SendGrid. I haven't found any way to do this elegantly, so that you could just call a parameter from the JSON and pass it along the mail call.

    However, there are still way we could build this :)

    Microsoft Flow

    Using a flow we can trigger it from a HTTP request and have it parse the input. Once the input is parsed we can get the relevant parameters and form the SendGrid URL for sending the email.

    This approach is a bit more involved but it opens a lot more doors for setting up all kinds of logic an alert could trigger.

    See this link for how to create a flow triggered from a HTTP request.