Reputation: 4484
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?
Thanks!
Upvotes: 2
Views: 2453
Reputation: 7392
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.
Upvotes: 5