How to set maxAutoLockRenewalDuration the on NSB endpoint hosted in azure function

Scenario: we have a handler which will run for 30 mins, the default lock time is 5 mins, how do we increase this to 30 mins in an NSB endpoint hosted in azure.

tried the following setting from this link Configuration • Azure Service Bus Transport • Particular Docs,

but we are not able to set the property and see the error " Azure Functions endpoints do not control the message receiver and cannot decide the lock renewal duration.

Question: How do we set maxAutoLockRenewalDurati on the on NSB endpoint hosted in azure function

I have the following code in the azure function’s Program.cs.


//#region configuration-with-function-host-builder
[assembly: NServiceBusTriggerFunction("NSBTest")]



var host = new HostBuilder()
  .UseNServiceBus((configuration, nsb) =>
  {
     

      nsb.AdvancedConfiguration.EnableOpenTelemetry();
      var outbox = nsb.AdvancedConfiguration.EnableOutbox();
      outbox.TimeToKeepOutboxDeduplicationData(TimeSpan.FromDays(configuration.GetValue<double>("OutBoxTimeSpan")));
      nsb.AdvancedConfiguration.UseSerialization<NewtonsoftJsonSerializer>();

  })
    .Build();

host.Run();

Thanks -Nen

Hi Nen!

When hosting in Azure Functions NServiceBus is not in control over the receive operation (that is why you see that error from our analyser) and can’t influence things like the auto lock renewal duration.

To change the lock renewal duration you need to change the configuration of the Azure Service Bus binding itself. See Azure Service Bus bindings for Azure Functions | Microsoft Learn for more details.

Hope this helps!

Cheers,

Andreas

Got it working with the following setting thank you.
AzureFunctionsJobHost__extensions__serviceBus__maxAutoLockRenewalDuration": “00:20:00”

1 Like