Send alert on failure of webjobs in azure portal

860 Views Asked by At

There is one requirement to send an email upon unsuccessful web-jobs only. There are 16 web-jobs which are deployed and running successfully on azure portal. I have suggested to modify the code for existing web-job but client does not want to modify web-jobs. He wants to add something extra which does not require to modify web-jobs anymore. I am confused, without modifying web-jobs, how can I send an email? I searched a lot on google and stack-overflow but didn't get anything.

How can I implement this?

1

There are 1 best solutions below

0
AudioBubble On

Few of the workarounds for getting the notification to email for WebJobs Status:

  • Using ErroTrigger and SendGrid extensions. you can do the Notifications sending to email for the WebJob SDK.

  • check this article on how to set that up which uses both extensions to send an email if an error occurred 10 times in 30 minutes window with a throttle up to 1 hour.

public static void ErrorMonitor(
    [ErrorTrigger("0:30:00", 10, Throttle = "1:00:00") TraceFilter filter,
    [SendGrid] SendGridMessage message)
{
    message.Subject = "WebJobs Error Alert";
    message.Text = filter.GetDetailedMessage(5)
}

If you aren't using the WebJob SDK, then unfortunately there aren't any events for continuous webjobs. There is only one for triggered jobs.

Also, visit this MSFT Doc and SO Thread for information on setting up the email alerts with App Services.