1
votes

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

1
I'm trying to understand your needs. Is there some reason you can't just enter the recipient email in the email field just above the webhook field?kim
I want the mail to be customised. Like proper subject lines and mail body.So I'm in need of using sendgrid api for customising it.user8884899
Microsoft Flow should be able to do that. Receive the event as a request in Microsoft Flow and there process the data sent by the alert and pass it along to sendgrid. See my answer below.kim

1 Answers

2
votes

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.