Edit

Share via


Create or join parallel branches of workflow actions in Azure Logic Apps

Applies to: Azure Logic Apps (Consumption + Standard)

By default, actions in a logic app workflow run sequentially. To organize actions into separate branches and run those branches at the same time, create parallel branches. You can join those branches later in your workflow.

This guide shows how to create parallel branches in a workflow and rejoin those branches, as shown in this example workflow:

Screenshot shows an example workflow with parallel branches that later merge together.

Tip

In scenarios where you have a workflow trigger that receives and returns arrays, and you want a separate workflow instance to run for each array item, you can debatch the array as an alternative to branching. On triggers that support this capability, in the designer, you can turn on the Split on setting, which maps to a splitOn property in the trigger definition. Only triggers that can accept and return arrays support this capability. For more information, see Trigger multiple runs on an array.

Prerequisites

Considerations for working with parallel branches

  • A parallel branch runs only when its runAfter property value matches the parent action's completed status. For example, both the branches branchAction1 and branchAction2 run only when parentAction completes with Succeeded status.

  • Your workflow waits for all parallel branches at the same level to complete before the workflow runs the action that joins these branches.

Add a parallel branch action

  1. In the Azure portal, open your logic app resource.

  2. Based on whether you have a Consumption or Standard logic app, follow the corresponding step:

    • Consumption

      • On the resource sidebar, under Development Tools, select the designer to open the workflow.
    • Standard

      1. On the resource sidebar, under Workflows, select Workflows.

      2. On the Workflows page, select a workflow.

      3. On the workflow sidebar, under Tools, select the designer to open the workflow.

  3. Between the actions where you want to add a parallel branch, hover over the connecting arrow.

  4. Select the plus sign (+) that appears, and then select Add a parallel branch.

    Screenshot shows a workflow with selected plus sign and selected option, Add a parallel branch.

  5. Add the action that you want to run in the parallel branch. In the Add an action pane and search box, find and select the action that you want.

    Screenshot shows a workflow with search box named Choose an operation.

    The selected action now appears in the parallel branch:

    Screenshot shows a workflow, parallel branch, and previously selected action.

  6. To add another action to the parallel branch, under the action where you want to add a new action, select the plus (+) sign, and then select Add an action.

    Screenshot shows a workflow and how to add another action to the same parallel branch.

  7. In the Add an action pane and search box, find and select the action that you want.

    Your selected action now appears within the current branch:

    Screenshot shows a workflow with added sequential action.

To merge branches back together, join your parallel branches, as in a following section.

Parallel branch definition (JSON)

In code view, you can define the parallel structure in your logic app workflow's JSON definition instead.

{
  "triggers": {
    "myTrigger": {}
  },
  "actions": {
    "parentAction": {
      "type": "<action-type>",
      "inputs": {},
      "runAfter": {}
    },
    "branchAction1": {
      "type": "<action-type>",
      "inputs": {},
      "runAfter": {
        "parentAction": [
          "Succeeded"
        ]
      }
    },
    "branchAction2": {
      "type": "<action-type>",
      "inputs": {},
      "runAfter": {
        "parentAction": [
          "Succeeded"
        ]
      }
    }
  },
  "outputs": {}
}

Join parallel branches

To merge parallel branches under all the branches, add another action. This action runs only after all the preceding parallel branches finish running.

  1. In the Azure portal, open your logic app and workflow as described in the previous procedure.

  2. Under any of the parallel branches that you want to join, select the plus sign (+), and then select Add an action.

    Screenshot shows a workflow with selected plus sign.

  3. In the Add an action pane and search box, find and select the action you want to use for joining the branches.

    Screenshot shows a workflow, search box named Choose an operation, and available actions for joining parallel branches.

  4. On the designer, select the previously added action. After the action's information pane opens, select Settings.

  5. On the Settings tab, under Run after, open the Select actions list. Select the last action in each branch that must finish before the join action runs.

    The join action runs only after all the selected actions finish running.

    Screenshot shows a workflow, the action that joins preceding parallel branches, and selected actions to first finish running.

    When you finish, the selected action appears under the parallel branches that you want to join:

    Screenshot shows a workflow with the action that joins the preceding parallel branches.

Join definition (JSON)

In code view, you can define the join action in your logic app workflow's JSON definition instead.

{
  "triggers": {
    "myTrigger": { }
  },
  "actions": {
    "parentAction": {
      "type": "<action-type>",
      "inputs": { },
      "runAfter": {}
    },
    "branchAction1": {
      "type": "<action-type>",
      "inputs": { },
      "runAfter": {
        "parentAction": [
          "Succeeded"
        ]
      }
    },
    "branchAction2": {
      "type": "<action-type>",
      "inputs": { },
      "runAfter": {
        "parentAction": [
          "Succeeded"
        ]
      }
    },
    "joinAction": {
      "type": "<action-type>",
      "inputs": { },
      "runAfter": {
        "branchAction1": [
          "Succeeded"
        ],
        "branchAction2": [
          "Succeeded"
        ]
      }
    }
  },
  "outputs": {}
}