Today I integrate my Azure function with Application insight for application logging, especially to capture error stack-trace.
First I have written Azure function without try-catch block so It was showing correct status/Information in Monitor section and application insight as well.
Later I added try-catch block and logged some more data like
catch(Exception ex)
{
log.Error(inputData);
log.Error(ex.Message);
return req.CreateResponse(HttpStatusCode.InternalServerError);
}
You can see in below attachment, ResultCode is 500 with Green Status... Why? I think because of this issue Application Insight not showing this data in Error/Failed request query.
No record found in Application Insight
exceptions
|where operation_Id == "c5b5a345-fa11-4356-b769-b34d1c6619e5"
| order by timestamp desc
| project operation_Id , timestamp