Error handling in Azure Functions
Apply error handling in your Azure Functions to enhance robustness – an obvious choice you would think. However, with functions, you may forget about it as you quickly want to run code in the cloud.
Azure Functions allows you as a developer to integrate with Azure Storage blobs and queues, Service Bus queues, Cosmos DB and a few other Azure services through trigger and bindings. When integrating with these services you may run into errors raised by these services.
Based upon your scenario, you are building a function for your need to consider how to deal with errors. Some triggers provide a retry mechanism and by default retry five-times and after that write a message to a poison queue. These triggers with built-in retry support are:
- Azure Blob storage
- Azure Queue storage
- Azure Service Bus (queue/topic)
Furthermore, other bindings can return exception and errors, which you have to deal handle.
Lastly, you can create a Durable Functions solution with Azure Functions. With Durable functions, you apply error handling inside the orchestration function, as exceptions thrown in any activity function is marshalled back to the orchestrator function and thrown as a FunctionFailedException.
For more details on error handling in Durable Functions, read: Handling errors in Durable Functions (Azure Functions)
Always think about the reliability and robustness of your Azure Function. Therefore, consider retry policies and error handling for your Azure Functions!
Explore how Serverless360 could help manage and monitor your applications involving Azure Functions.