Logic Apps: How to add several actions inside a Logic App condition branch

  • Sandro Pereira
  • Apr 20, 2016
  • 6 min read

In my last blog post, I talked about the new The ability to call nested Logic Apps directly from Logic Apps Designer, and I mentioned that this great feature not only allows us to create reusable pieces, but that will allow us to overcome some of the current Logic Apps limitations:

  • The ability to add more than one action inside the condition branch (this is actually a false statement).
  • or the ability to add more than one action inside the loop.

In this post, we will address the first option; we will leave the second one for a dedicated post. Once again, in my previous post, we created a Logic App called AddFileToDropbox that:

  • It’s triggered manually, which means through an HTTP post, allowing it to be invoked by other Logic Apps.
  • Then it will call an Azure Function to dynamically generate a filename.
  • Create a Dropbox file:
    • The filename is provided by the Azure Function.
    • And the content of the message is passed in the HTTP request that triggers this Logic App.
  • And finally, return an HTTP response based on the status of the file creation.

We will reuse this “child” Logic App in our demos here.

📝 One-Minute Brief

This article explains a practical workaround for a classic Azure Logic Apps limitation: adding multiple actions inside a condition branch. By using nested Logic Apps, it demonstrates how to group and reuse actions within “If/Else” conditions, enabling cleaner workflows, better reuse, and more maintainable designs.

Our “basic” demo scenario

The important thing here is to demonstrate the concept itself, not whether this is a real case or not, so we will use connectors that are simple to test.

Let’s say that we want to listen to the #LogicApps Twitter hashtag, and:

  • If the tweet was made by someone other than me (@sandro_asp), then:
    • We need to call an Azure Function to dynamically generate a filename.
    • Create a Dropbox file:
      • The filename is provided by the Azure Function.
      • And the content of the message will be the actual tweet text message.
  • If it’s a tweet made by me, let’s say I want to send it in an email to… my manager (just to annoy him).

Creating a Logic App with conditions inside

Let’s create a Logic App called ConditionsInsideLogicApp (you can see the basic steps in my previous posts)

  • Add a Twitter – When a new tweet appears trigger, to look for a new tweet containing the hashtag #LogicApps.
Logic Apps Conditions Add Tweet Appear
  • Select the plus sign, and then choose Add a condition.
Logic Apps Conditions Add a condition

Note: if by any chance, you verify that the conditions branches, if yes and if no, do nothing, are not side-by-side as would be expected, but instead they are in sequence, one under the other:

Logic Apps Conditions note

Do not be alarmed, there is nothing wrong with your editor. It just means that your monitor does not have enough resolution, you are using a large zoom, or your browser window is too small to render the conditions side by side. If you switch to a different monitor or zoom out, you will see that they will be rendered side-by-side:

Logic Apps Conditions side by side
  • Now that we have the condition action, we need to configure it in the following manner:
    • In the Object name property, we need to set the parameter Tweet by from the output of the When a new tweet appears trigger.
    • In the Relationship property, we need to choose the option is not equal to.
    • And finally, on the Value property, we need to statically set the value @sandro_asp.
Logic Apps Conditions Tweet condition configuration

Note: If we look to our If yes branch we will see that we only have the ability to Add an action with means that we cannot create, at least for now, nested conditions (you probably can if you call another Logic App).

Logic Apps Conditions add action if branch
  • If we go to our If yes branch and Add an action.
    • From the search box, select “Show Azure Functions in my subscription” and select the Azure Function: “CreateFileName” and set the “Input payload object” as an empty JSON message:
{ }
Logic Apps Conditions add action if First action

Based on your user experience in the Logic App designer, you may think that you cannot add more actions inside the “If yes” branch because you don’t have the plus sign underneath the Call Azure Function action. Well, you are wrong!

You actually can add several actions (conditions are not allowed) inside the same branch, by clicking once again on the Add an action on the top right corner.

Logic Apps Conditions add action if second action
  • From the search box, type Dropbox and select the Dropbox – Create file action.
    • Set the Folder path, let’s say the root by typing: /.
    • Click on the Filename and set the parameter “Body” from the output of the CreateFileName function as input.
    • Switch to code view to edit the Create file inputs to have the expected values:
@{body('CreateFileName')['FileName']}
  • And then click on the File content text box, and set the parameter Text from the output of When an HTTP request is received as input.
Logic Apps Conditions add action if no email action

At the end, your Logic App will have a condition with:

  • Two actions in the If yes branch.
  • And one action in the if no branch.
Logic Apps conditions

Save your logic app and wait to a tweet to appear, we will see that a new file was added to your Dropbox or an email was sent to your manager.

Second option

Because we already created a Logic App that makes the necessary steps for the condition “If yes“:

  • Generate a filename.
  • And create a file in Dropbox.

Instead of having several actions, creating and repeating the same steps over and over again, we can call the AddFileToDropbox to do the same steps for us.

Logic Apps Conditions add action if call Logic App

Advantages of this approach:

  • We are reusing code.
  • We can add “nested” conditions.

Disadvantages:

  • We lose a little of the run action history because we then have the action AddFileToDropbox, but we cannot easily go to the child run and correlate the existing runs.
Logic Apps Conditions runs action history
Logic Apps Conditions runs action history

Explore more on: Tracking Message Properties

Hope you find this helpful! If you liked the content or found it useful and would like to support me in writing more, consider buying (or helping to buy) a Star Wars Lego set for my son. 

Thanks for Buying me a coffe
Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.

Leave a Reply

Your email address will not be published. Required fields are marked *

The Ultimate Cloud
Management Platform for Azure

Supercharge your Azure Cost Saving

Learn More
Turbo360 Widget

Back to Top