Handle Azure Functions binding errors

Errors raised in an Azure Functions can come from any of the following origins:

  • Use of built-in Azure Functions triggers and bindings
  • Calls to APIs of underlying Azure services
  • Calls to REST endpoints
  • Calls to client libraries, packages, or third-party APIs

Following solid error handling practices is important to avoid loss of data or missed messages. Recommended error handling practices include the following actions:

Use structured error handling

Capturing and publishing errors is critical to monitoring the health of your application. The top-most level of any function code should include a try/catch block. In the catch block, you can capture and publish errors.

Retry support

The following triggers have built-in retry support:

By default, these triggers retry requests up to five times. After the fifth retry, both the Azure Queue storage and Azure Service Bus triggers write a message to a poison queue.

You need to manually implement retry policies for any other triggers or bindings types. Manual implementations may include writing error information to a poison message queue. By writing to a poison queue, you have the opportunity to retry operations at a later time. This approach is the same one used by the Blob storage trigger.

For information on errors returned by services supported by Functions, see the Binding error codes section of the Azure Functions error handling overview article.