Forum Discussion

Ivan Buzyka's avatar
Ivan Buzyka
Copper Contributor
May 25, 2021

Trying to use retryOptions for service bus trigger on Azure Functions

I am just trying to follow https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus#additional-settings-for-version-5x in order to customize retrying behavior on the service bus trigger (which is I believe 10 attempts with a small interval in between).

It seems to be not working (It runs 10 times before service bus message goes to dead letter. It does not take into account appropriate settings from host.json file)

I have https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.ServiceBus/5.0.0-beta.3 5.x Extension referenced by Nuget.

 

Here is my very basic example:

 

 

using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;

namespace CH.AF.SampleBox
{
    public static class TestSbRetry
    {
        [FunctionName("TestSbRetry")]
        //[FixedDelayRetry(5, "00:00:30")]
        public static void Run([ServiceBusTrigger("test2", Connection = "Sbus2")]string myQueueItem, ILogger log)
        {
            log.LogInformation($"Attempt to run dunction at {DateTime.Now}");
            log.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
            throw new ApplicationException("artificial exception to test retry");
        }
    }
}

 

 

And the host.json

 

 

 

{
  "version": "2.0",
  "extensions": {
    "serviceBus": {
      "serviceBusOptions": {
        "retryOptions": {
          "mode": "fixed",
          "tryTimeout": "00:01:00",
          "delay": "00:00:20.00",
          "maxDelay": "00:01:00",
          "maxRetries": 2
        }
      }
    }
  },
  "logging": {
    "fileLoggingMode": "always",
    "logLevel": {
      "default": "Trace",
      "function": "Trace",
      "Host.Aggregator": "Trace"
    },
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": false
      },
      "enableLiveMetrics": true
    }
  }
}

 

 

 

Does anybody have any idea what I am missing?

No RepliesBe the first to reply

Resources