Which Azure Function Support In-built retry policy

Satyam Chauhan 467 Reputation points

Hi, I am using cosmos DB trigger, timer trigger and Event HUb trigger azure functions. I want to implement retry mechanism in the function. After going through the article - https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-error-pages?tabs=exponential-backoff%2Cin-process&pivots=programming-language-csharp#retries, it is stated that not all functions supports retry policy by default and it has to be implemented. Please let me know for which functions we need to implement retry on our own.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,018 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Dronec 161 Reputation points

    Sure, here it is:

    public static async Task Run.....
     var retryCount = 0; // Retries counter
     while (true)
    ... whatever you do in your function
     catch (Exception ex)
         if (retryCount >= 5)
             log.LogError($"Error {ex.message} happened, {retryCount} attempt.");
    log.LogInformation($"Error {ex.message} happened, {
    0 comments No comments

  2. Mike Urnun 9,236 Reputation points Microsoft Employee

    Hello @Satyam Chauhan - Thanks for posting on the MS Q&A & engaging the community here. AFAIK, among the CosmosDB, Timer, and Event Hubs triggers that you named, TimerTrigger is the only one where the Retry policy behavior opts to follows:User's image

    When it runs again next time per schedule, the timer object passed into the function will have its isPastDue set to true:

            "AdjustForDST": true
        "ScheduleStatus": {

    For CosmosDB and Event Hubs triggers, you should be able to implement the built-in FixedDelay and ExponentialBackOff policies accordingly. Hope this helps. Feel free to tag me in the comments below if you have any follow-up questions.

    Please "Accept Answer" if the answer is helpful so that others in the community may benefit from your experience.

    0 comments No comments