Running a Single Instance of a Azure Logic App

1 minute read

In certain scenarios you want to run a Single Instance off a Azure Logic App every time. Scenarios were you need this is when containers are created within your flow and the other messages are also depending on the same containers.

Solution

Together with a colleague of mine we searched for a solution and finally found the answer after having contact with Microsoft. The trigger component within a Logic App has a property called “operationOptions”. This property can be set to “SingleInstance” this will make sure the Logic App will only be trigged per message.

Example

"triggers": {
  "When_a_message_is_received_in_a_topic_subscription": {
    "type": "ApiConnection",
    "inputs": {
      "host": {
        "api": {
          "runtimeUrl": "https://logic-apis-westeurope.azure-apim.net/apim/servicebus"
        },
        "connection": {
          "name": "[name]"
        }
      },
      "method": "get",
      "path": "[path]"
    },
    "operationOptions": "SingleInstance",
    "recurrence": {
      "interval": 1,
      "frequency": "Minute"
    }
  }
}

The code snip-it above is a Service Bus trigger for new messages within a topic. By adding the “operationsOptions” this Logic App will only be triggered once per message.

Disadvantage

When using the “operationsOptions” property you have to keep in mind that only one instance will run within your interval. For example when there are 5 messages within the topic, and the Logic App is triggered once every minute it will get one message from the topic every minute and will not run a new flow if the preceding message is processed. In this example it will take about 5 minutes to process the 5 messages depending on how long your Logic Apps runs.