I have created a triggered webjob using Java as a technology stack and it is running fine after deployment. But now I want to monitor this webjob using alert notification. I tried multiple things, like adding app insights dependencies in POM file and using instrumentation key but nothing is working out. If anyone can guide me how to set an alert for webjob failure, it will be so helpful. Thanks.
Update:
As Sdcoder commented:
I am calling application-insight agent jar from the run.sh file. It solved my problem, I am able to see the logs in the app insights now. my
run.sh
file looks like this:set PATH=%PATH%;%JAVA_HOME%/bin java -javaagent:applicationinsights-agent-3.0.2.jar -jar app.jar
As suggested by ahmelsayed:
private async void ReportTriggeredJobFinished(string jobName, string jobRunId)
{
TriggeredJobRun triggeredJobRun = GetJobRun(jobName, jobRunId);
if (triggeredJobRun == null)
{
return;
}
await _hooksManager.PublishEventAsync(HookEventTypes.TriggeredJobFinished, triggeredJobRun);
}
}
You can refer to Azure WebJob, how to be notified if it stops? and Best way to set up alerts on azure web job