Azure Function Service Bus Trigger

Alessandro Pirovano 1 Reputation point
2022-04-11T19:47:48.867+00:00

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 Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
544 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,249 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Mike Urnun 9,666 Reputation points Microsoft Employee
    2022-04-12T17:48:23.767+00:00

    Hello @Alessandro Pirovano - 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://learn.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.

    0 comments No comments