question

AlessandroPirovano-6164 avatar image
0 Votes"
AlessandroPirovano-6164 asked MikeUrnun edited

Azure Function Service Bus Trigger

Hi,
I have an Azure Function, with consumption plan, triggered by a Service Bus message, I need that the functions process one or two messages at time.
I limited the instances to one:
192007-immagine-2022-04-11-214344.png


And in the host.json of the function I used maxConcurrentCalls at 1.

192042-immagine-2022-04-11-214659.png

However, the function keeps firing multiple times for different messages.
What can I do to limit the executions?

Thanks.


azure-functionsazure-service-bus
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

MikeUrnun avatar image
0 Votes"
MikeUrnun answered MikeUrnun edited

Hello @AlessandroPirovano-6164 - Thanks again for reaching out & posting on the MS Q&A channel!

You do have the correct & minimal configuration for achieving the "one message at a time" processing. The reason why it may not be working as intended is probably that you have Version 5.x of the Service Bus Extension installed but yet in the host.json file, you seem to be using the messageHandlerOptions wrapping the maxConcurrentCalls setting, which is an implementation for previous versions of the Service Bus extension.

If you, indeed, have the v5 of the Service Bus extension, you could omit the messageHandlerOptions wrapper as follows:

 {
    "version": "2.0",
   "extensions": {
     "serviceBus": {
       "serviceBus": {
         "maxConcurrentCalls": 1
       }
     }
   }
 }

Alternatively, if you want to use the previous version of the Service Bus extension, you'll want to install the right version. For example, here's the NuGet package of the extension for version 4.3.0 (which will support your current setting in the host.json file): https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.ServiceBus/4.3.0

For a full reference on the exact differences between in host.json file based on your target Service Bus extension version, please review our official doc: https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus?tabs=in-process%2Cextensionv5%2Cextensionv3&pivots=programming-language-csharp#hostjson-settings

I hope this helps resolve the issue but if you continue to hit the same issue, let me know and we can dig deeper.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.