How to handle error & retry ?
Retries
The retry behavior is configured at different places because all triggers (binding) do not support the same retry policy.
Trigger/binding | Retry source | Configuration |
---|---|---|
Azure Cosmos DB | Function-level | |
Azure Blob Storage | ||
Azure Event Grid | Event subscription | |
Azure Event Hubs | Function-level | |
Azure Queue Storage | ||
RabbitMQ | ||
Azure Service Bus | ||
Timer | Function-level | |
Kafka | Function-level |
Here’s an example at the function level for Azure Event Hubs
[FunctionName("EventHubTrigger")]
[FixedDelayRetry(5, "00:00:10")]
public static async Task Run([EventHubTrigger("myHub", Connection = "EventHubConnection")] EventData[] events, ILogger log)
{
// ...
}
Error Codes
With the integration with Azure services, errors might originate from APIs : Azure Functions error handling and retry guidance | Microsoft Learn
See the example for Azure Cosmos Db : HTTP Status Codes for Azure Cosmos DB | Microsoft Learn
See the example for Blob Storage : Azure Blob storage output binding for Azure Functions | Microsoft Learn
etc.