I have Azure Function (Http trigger) that can fail. I also have Application Insights configured for it.
In case of error (Which is better):
Application Insight is able log exceptions. I don't really see point in logging error and throwing exception at the same time.
What are the guidelines? What is good practise?
In the path of Storage Account > File Shares (under Data Storage) > Your Function App > LogFiles > Application > Functions > Function > Your Function Name > You can see the console result (Application Logs - Execution results/failed result/error data) of the function.
To view streaming logs in the portal, select the Platform features tab in your function app. Then, under Monitoring, choose Log streaming. This connects your app to the log streaming service and application logs are displayed in the window. You can toggle between Application logs and Web server logs.
The Azure Function Timeout is difference depending on which hosting method / pricing tier is used to host an Azure Function App. While in the Consumption plan, the default timeout is 5 minutes, there is a different default and maximum timeouts for the Premium and Dedicated pricing tiers.
The HTTP trigger lets you invoke a function with an HTTP request. You can use an HTTP trigger to build serverless APIs and respond to webhooks. The default return value for an HTTP-triggered function is: HTTP 204 No Content with an empty body in Functions 2.
You need to be able to tell when your Azure Functions apps cause problems. And in order to monitor for errors, you need to be able to log them! In a web server-hosted process, you would normally connect some kind of global logger to catch and log exceptions. You would use that same logger to log from your code.
You need to be able to tell when your Azure Functions apps cause problems. And in order to monitor for errors, you need to be able to log them! In a web server-hosted process, you would normally connect some kind of global logger to catch and log exceptions.
1) Add the Raygun client package to your function code. 2) Add the code to create a client. 3) Send the exception. This is the most basic way to send exceptions to Raygun from your Azure Functions apps. Of course, you can take things up a few levels from here. Let’s take a look at some things you can do to improve on this approach. 1.
Thank you. Handling errors in Azure Functions is important to avoid lost data, missed events, and to monitor the health of your application. This article describes general strategies for error handling along with links to binding-specific errors.
From my experience which is building an HTTP triggered azure function with Python, I noticed that: When handling exceptions and then manually return something to the client you do have control over the function returned value but the framework marks the function's job as 'Succeeded', which then makes it more difficult to be tracked & monitored in the Application Insights.
For your question, I ended up with a catch clause that mixes 1 & 3 i.e a hybrid approach where I try to identify the origin of the exception, then for exceptions from my code I'm wrapping it and return 500, and for other exceptions that originated from code that I'm using I re-throw them and let the azure function framework return a 500 and to mark the function's job as 'Failed'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With