Search code examples
azureazure-functionsazure-servicebus-queues

How to config service bus function 2.x for max retry count?


By default the Azure service bus queue binding function will have a retry count of 10, is there anyway to custom this value in either host.json or local.settings.json file? I've read about the microsoft document, which introduce four variables (prefetchCount, autoComplete, maxConcurrentCalls, maxAutoRenewDuration) but none of them looks like what I need, in addition, are those all the settings we could configure for service bus binding functions? Could we have something like max-retry, retry-interval, scale count?


Solution

  • Maximum Delivery Count is a property of the queue itself.

    You can imagine the problems that might occur if this could be overridden in software. Assume that process A is monitoring a Service Bus Queue and sets its max delivery count to 5, while process B is also monitoring the same queue, but sets its max delivery count to 10. If this were the case, Process A would force a deadletter of an undeliverable message after 5 attempts, but Process B would be expecting to get ten attempts. So the only way to change max delivery count is to set the property on the Service Bus Queue itself.

    You can sidestep this by dequeuing a message completely, then re-enqueuing within a catch block instead of relying on the queue's internal retry logic. Then you can do whatever you want.