Azure Logic Apps Running Anywhere - Built-In Service Bus Trigger: batching and session handling
Published Jan 20 2021 12:38 PM 6,920 Views

Built-In Service Bus Trigger: batched message processing and session handling

Logic App Refresh preview provides us with the option to create a built-in Service Bus trigger to receive messages from Service Bus topic or queue.

In this blog post two advanced Service Bus message processing are discussed:

  • Azure Service Bus batch processing and how to configure the max batch count of messages.
  • Messages processing in Logic App for the session-aware Service Bus queues or subscriptions.

Service Bus queue batch processing:

To improve the message retrieval performance for Service Bus queue, it is highly recommended to receive the messages in batch. The Logic App Service Bus trigger for queue by default supports array of Service Bus messages as output.



The prefetchCount is used to specify how many messages should be retrieved in a "batch" to save the roundtrips from Logic Apps back to the Azure Service Bus. Prefetching messages increases the overall throughput for a queue by reducing the overall number of message operations, or round trips.

The prefetchCount can be configured in the global configuration settings in host.json, the Azure function trigger requests these many messages for the Azure Function.




    "version": "2.0",
    "extensions": {
        "serviceBus": {
            "prefetchCount": 20,
            "messageHandlerOptions": {
                "autoComplete": true,
                "maxConcurrentCalls": 32,
                "maxAutoRenewDuration": "00:05:00"




The host.json can be edited using Kudu Advance tool (in case the Logic App is created in Azure Portal).




Message processing for session-aware service bus queue/subscriptions:

You can enable the session by selecting the Enable sessions checkbox while creating the Service Bus queue in UI :



In the session-aware Service Bus queue the built-in Service Bus trigger cannot receive the message by default. The sessions are not enabled for Service Bus trigger by default.

The Azure Service Bus trigger is based upon Azure Function ServiceBusTrigger binding configuration of Azure function, the isSessionsEnabled configuration needs to set for it to enable the session processing. This option can be handled in the logic app code definition as given below:




        "triggers": {
            "When_messages_are_available_in_Service_Bus_queue": {
                "inputs": {
                    "parameters": {
                        "isSessionsEnabled": true,
                        "queueName": "psrivassbq5"




Once you update the Logic App definition you can view this in the designer as shown below. However, the isSessionsEnabled trigger input option cannot be configured on the designer surface. The input option IsSessionEnabled in UI will be provided in the Logic App Refresh future release.




When the messages are queued in Service Bus session queue, it will trigger the Service Bus trigger based upon sessions in Service Bus queue. You can use the SessionId  property from Service Bus trigger output.


Version history
Last update:
‎Jan 20 2021 07:27 PM
Updated by: