Azure WebJob, how to be notified if it stops?

淺唱寂寞╮ 提交于 2019-12-06 13:05:18

If you're using the WebJob SDK, then you can do that using the new ErrorTrigger and SendGrid extensions. Check this wiki on how to set that up. But here is a sample code (copied from the wiki above) that 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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!