Azure WebJob,如何停止通知? [英] Azure WebJob, how to be notified if it stops?

查看:74
本文介绍了Azure WebJob,如何停止通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个持续运行的天蓝色webjob.如果它停止或中止,我想得到通知.是否有一个停止或中止而我可以触发电子邮件的事件被调用?

I have an azure webjob that runs continuously. I'd like to be notified if it stops or is aborted. Is there an event that gets called on stop or abort that I can trigger an email?

谢谢!

推荐答案

如果使用的是WebJob SDK,则可以使用新的ErrorTriggerSendGrid扩展名来实现.检查此有关如何进行设置的维基.但是,这里有一个示例代码(从上面的Wiki复制),如果在30分钟的窗口内发生10次错误,并且节气门长达1小时,则使用这两个扩展名发送电子邮件.

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)
}

如果您不使用WebJob SDK,那么很遗憾,连续Web作业没有任何事件.有仅用于触发的工作.

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.

这篇关于Azure WebJob,如何停止通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆