0

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?

James Z
  • 12,209
  • 10
  • 24
  • 44
You Me
  • 11
  • 2
  • Is your ask related to how to create alerts if the azure function app fails to run and send the email? –  Feb 15 '22 at 23:13
  • Not azure function, I have created azure webjobs and deployed it successfully in azure app service. Need to send an email if azure webjobs fails, but dont want to modify the webjobs. – You Me Feb 15 '22 at 23:38
  • Can you poll the REST API? https://learn.microsoft.com/en-us/rest/api/appservice/web-apps/get-triggered-web-job-history – Skin Feb 16 '22 at 03:51
  • { "error": { "code": "AuthenticationFailedInvalidHeader", "message": "Authentication failed. The 'Authorization' header is provided in an invalid format." } } – You Me Feb 16 '22 at 10:48
  • getting error while calling from postman. where can I get authorized access token? – You Me Feb 16 '22 at 10:48
  • Yes Now I am able to get the value. – You Me Feb 16 '22 at 12:57

1 Answers1

0

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.