How to enforce Azure Function app to process Service Bus Queue messages one at a time
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"
}
}
}
}