Share via

Logic app Servce Bus trigger with session creates duplicated runs for the same message

Tomasz Kaniewski 5 Reputation points
2026-02-11T12:50:48.7366667+00:00

Hi, I'm playing with service bus sessions and logic apps and I have problem with duplicated runs for the same message when using sessions in Logic app. This is my publisher logic app:

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "contentVersion": "1.0.0.0",
        "actions": {
            "For_each": {
                "type": "Foreach",
                "foreach": "@range(0, 5)",
                "actions": {
                    "Send_message": {
                        "type": "ServiceProvider",
                        "inputs": {
                            "parameters": {
                                "entityName": "sb-tk-sess-poc",
                                "message": {
                                    "contentData": {},
                                    "sessionId": "1"
                                }
                            },
                            "serviceProviderConfiguration": {
                                "connectionName": "serviceBus",
                                "operationId": "sendMessage",
                                "serviceProviderId": "/serviceProviders/serviceBus"
                            }
                        }
                    }
                },
                "runAfter": {}
            },
            "For_each-copy": {
                "type": "Foreach",
                "foreach": "@range(0, 5)",
                "actions": {
                    "Send_message_1": {
                        "type": "ServiceProvider",
                        "inputs": {
                            "parameters": {
                                "entityName": "sb-tk-sess-poc",
                                "message": {
                                    "contentData": {},
                                    "sessionId": "2"
                                }
                            },
                            "serviceProviderConfiguration": {
                                "connectionName": "serviceBus",
                                "operationId": "sendMessage",
                                "serviceProviderId": "/serviceProviders/serviceBus"
                            }
                        }
                    }
                },
                "runAfter": {}
            }
        },
        "outputs": {},
        "triggers": {
            "When_an_HTTP_request_is_received": {
                "type": "Request",
                "kind": "Http"
            }
        }
    },
    "kind": "Stateful"
}

User's image

Very simple LA with HTTP trigger that puts 5 messages with sessionId = 1 and 5 messages with sessionID = 2.

This is my topic - subscription configuration:
User's image

User's image

nothing fancy here either, default settings with sessions enabled and lock set to 5min.

Last one is my subscriner logic app:

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "contentVersion": "1.0.0.0",
        "actions": {
            "Delay": {
                "type": "Wait",
                "inputs": {
                    "interval": {
                        "count": 20,
                        "unit": "Second"
                    }
                },
                "runAfter": {}
            },
            "Close_a_topic_session": {
                "type": "ServiceProvider",
                "inputs": {
                    "parameters": {
                        "topicName": "sb-tk-sess-poc",
                        "subscriptionName": "sb-tk-sess-poc",
                        "sessionId": "@triggerBody()?['sessionId']"
                    },
                    "serviceProviderConfiguration": {
                        "connectionName": "serviceBus",
                        "operationId": "closeTopicSession",
                        "serviceProviderId": "/serviceProviders/serviceBus"
                    }
                },
                "runAfter": {
                    "Complete_the_message_in_a_session": [
                        "SUCCEEDED"
                    ]
                }
            },
            "Complete_the_message_in_a_session": {
                "type": "ServiceProvider",
                "inputs": {
                    "parameters": {
                        "messageId": "@triggerBody()?['messageId']",
                        "lockToken": "@triggerBody()?['lockToken']"
                    },
                    "serviceProviderConfiguration": {
                        "connectionName": "serviceBus",
                        "operationId": "completeMessageInSession",
                        "serviceProviderId": "/serviceProviders/serviceBus"
                    }
                },
                "runAfter": {
                    "Delay": [
                        "SUCCEEDED"
                    ]
                }
            }
        },
        "outputs": {},
        "triggers": {
            "On_new_messages_from_topic_session": {
                "type": "ServiceProvider",
                "kind": "Polling",
                "inputs": {
                    "parameters": {
                        "topicName": "sb-tk-sess-poc",
                        "subscriptionName": "sb-tk-sess-poc",
                        "maxMessages": 1
                    },
                    "serviceProviderConfiguration": {
                        "connectionName": "serviceBus",
                        "operationId": "onNewMessagesFromTopicSession",
                        "serviceProviderId": "/serviceProviders/serviceBus"
                    }
                },
                "recurrence": {
                    "interval": 10,
                    "frequency": "Second"
                },
                "splitOn": "@triggerOutputs()?['body']"
            }
        }
    },
    "kind": "stateful"
}

User's image

Trigger is configured to run every 10s, delay is set to 20s. Now lets look at the runs history:

User's image

only two session was created so I expected to see 2 runs trigger as similar time, but sometimes 3 runs are created (take a close look at trigger time), when I checked the trigger output details it turns out 2 runs were created for the same message. Later one instance failes because it tries to complete the message that was already completed.

User's image

I tired both session triggers: "onNewMessagesFromTopicSession" and "onSingleNewMessageFromTopicSession" and both have above issue. How can I solve it?

Azure Service Bus
Azure Service Bus

An Azure service that provides cloud messaging as a service and hybrid integration.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Praveen Kumar Gudipudi 2,275 Reputation points Microsoft External Staff Moderator
    2026-02-11T15:36:10.4066667+00:00

    Hello Tomasz Kaniewski ,

    Could you please configure Concurrency control setting to 1 to both HTTP trigger and service bus trigger avoid duplicate runs (it won't allow logic app parallel runs)

    User's image

    User's image

    Please accept as answer and do a Thumbs-up to upvote this response if you are satisfied with the community help. Your upvote will be beneficial for the community users facing similar issues.


Your answer

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