How to enforce Azure Function app to process Service Bus Queue messages one at a time

MTB Holdings Pty Ltd 0 Reputation points
2024-09-19T23:28:59.14+00:00

Hey all

Prior to migrating to .Net 8 Isolated, our function app was on the .Net 6 In-Process model.

We configured our app to always consume service bus messages one at a time via our host.json file (see config below). However, with .Net 8 Isolated, we are seeing some unexpected behaviour.

We have a HTTP Trigger function set up to accept webhooks from an external platform - this function then passes the messages onto the Service Bus queue. We can sometimes see thousands of messages being placed on the queue in quick succession. In the past, our function app would process these one by one, however, since moving to .Net 8 isolated we have noticed the function app will consume hundreds of messages at a time which is leading to some rate limiting issues in the systems the service bus trigger function is sending the data onto.

However, if we disable the Service bus trigger function from running, dump a bunch of messages on the queue, and then enable the function again, it will process the messages one at a time.

We don't want to limit scale out of the whole function app to one instance, is there any way to just change the service bus trigger functions consume one message at a time without affecting all of the other functions in the app?


{
  "version": "2.0",
  "extensions": {
    "serviceBus": {
      "prefetchCount": 1,
      "messageHandlerOptions": {
        "maxConcurrentCalls": 1
      },
      "sessionHandlerOptions": {
        "autoComplete": false,
        "maxConcurrentSessions": 1
      },
      "batchOptions": {
        "maxMessageCount": 1
      }
    }
  },
  "functionTimeout": "00:10:00",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  }
}

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
620 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,948 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.