1

I have an app service which sends Service Bus Message to my Azure Service Bus Queue - this works fine. Then my Azure Function, which is a Bus Trigger, receives message from Azure Service Bus Queue. The problem is that after about 10 minutes, when the first (previous) trigger has not completed its work, Azure Function receives message from bus queue again. Its problem for me because executing logic can take up to 45 minutes.

I have read quite a bit and have not found a solution. First of all, I tried to solve this problem using the settings from the host.json file, code:

    "extensions": {
        "serviceBus": {
            "messageHandlerOptions": {
                "autoComplete": true,
                "maxConcurrentCalls": 1,
                "maxAutoRenewDuration": "23:59:00"
            }
        }
    },
    "functionTimeout": "23:59:00"

I have read that I should set the maxAutoRenewDuration parameter to a little larger, as it is responsible for renewing the message lock. Also, the functionTimeout parameter should exceed the maximum duration of the activity. With these options, Azure Function received the same message every 10-12 minutes. Without these parameters it was equal to 5 minutes. Some progress, but not enough.

Secondly, I read about "PeekLock behavior", which, from what is written in the documentation, automatically refreshes the message lock when the function is running - Source And that would be perfect, but I don't know why it is not working. Should I set it up in some way?

What I expect:

  • That the Azure Service Bus Queue message will not be processed multiple times, at least as long as the first (previous) trigger is working.
  • Another solution that suits long processing.

My environment: .NET 6; Azure Function ver. 4.2.1; Azure Function Premium Plan (It is worth noting, because in the consumption plan it cannot run for more than 10 minutes).

kmbrzoza
  • 11
  • 2
  • The host.json you provide seems like it should do the trick if you're using the premium plan. Have you checked and seen if the host.json actually deploys with the app? You can see this by going to the Kudu site: http://.scm.azurewebsites.net ([more info](https://stackoverflow.com/a/26385007/15354710)). To find the host.json config, append to the url so it becomes http://.scm.azurewebsites.net/api/functions/config – Isak Engström Mar 24 '23 at 17:01

0 Answers0