8

Can an Azure Logic App have multiple start triggers?

I've read the triggers docs at MSDN but can't see anything on having multiple triggers

SteveC
  • 15,808
  • 23
  • 102
  • 173
  • 2
    As far as I know not, way you could handle multiple triggers is by creating a logic app for each trigger you'd like an have them call another logic app which contains the actual processing of your triggers. – Steven Van Eycken Apr 10 '17 at 12:25

4 Answers4

10

In general yes, you can have multiple triggers in a Logic App workflow. Actually, according to the official documentation, you can have up to 10 triggers in a single Logic App. As example, in the following logic app, I used two triggers: the first one is a SFTP connector trigger and, after a sequence of actions I have a second trigger on a Service Bus queue (with the send message action I send a message for a webjob that performs a long running task and it notify the Logic app with a message on another queue that let it to continue its execution).

enter image description here Probably, what you mean instead is if it's possible to have multiple "starting" triggers to implement some kind of "or logic" between triggers. In this case I think the answer is no, and in order to achieve this I will go as well with what @Steven Van Eycken suggests: split Logic Apps in two of them, triggered by the two triggers you need and for example then send a message on a queue that triggers the third logic app with the common workflow.

Davis Molinari
  • 741
  • 1
  • 5
  • 20
5

I guess I'm a bit late to the party, but I have been able to create multiple triggers for a logic app.

In mine, I'm using the SFTP connector to trigger when a file is created or changed. The SFTP connector only allows one folder to be monitored but I didn't want to duplicate the logic app for each folder I want to monitor, so I've added three SFTP triggers to my app, each monitoring a different folder on the same SFTP site.

AFAIK you can only do this in the code view, and once you have multiple triggers you cannot get back to the designer view, but essentially I set up my logic app as I wanted it, then went into the code view, duplicated the trigger definition and changed the bits I needed to change (the name, the folder name and the folder ID).

Trigger history in the Overview screen then allows you to choose which of the triggers you want to see, but whichever trigger has fired, the rest of the logic app runs. You also lose the ability to see the workflow view of the historical runs, but with a few extra clicks you can see what's going on at each stage in the app.

It's a pain that it can only be done in the code view, but it is possible, certainly with the same type of trigger. I'm not sure about mixed trigger types, but I guess as long as you weren't relying on an output from one that doesn't exist in the others then it should be ok. I also tested it with multiple email triggers. Just bear in mind that if the connectors require different connections, you'll need to include each of the connections in your code. To start with it might be worth building each in a separate app then pasting the relevant bits of code in.

Steve
  • 66
  • 1
  • 1
  • Are you sure ? You can add multiple trigger in start of logic app to trigger logic app. – Rukhsar Ahmad Dec 09 '17 at 20:14
  • 1
    @Steve, I am trying to add multiple triggers - but whenever I go to overview and come back to code view it overrides it and now it has only one trigger. Also, how where did you add the trigger? inside "triggers" OR yu created another property "triggers" ? Small snippet or screenshot should help everyone looking to achieve such a requirement. – Jigar Sheth Mar 12 '18 at 03:04
  • Yeap, I've been able to add multiple triggers in the "triggers" element in the code view. Works fine. Only downer is you can't switch back to the designer view. – SteveC Aug 26 '20 at 11:25
3

This answer is continuation of @Steve answer. Steve has explained how it can be done, I am just going to add in some code snippet for more clarity.

Also, when I was testing this solution it didn't work for me for the second folder in the list of triggers while clicking "Run" from code view. Because I think "Run" by default runs the first trigger. So for testing purpose I have set the trigger time to 15 seconds so it is easier to test once you save it in code-view.

"triggers": 
{
"When_a_file_is_added_or_modified_folder1": {
  "inputs": {
    "host": {
      "connection": {
        "name": "@parameters('$connections')['sftp']['connectionId']"
      }
    },
    "method": "get",
      "path": "/datasets/default/triggers/onupdatedfile",
      "queries": {
        "folderId": "L2hvbWUvbmF3YQ==",
        "includeFileContent": true,
        "inferContentType": true,
        "queryParametersSingleEncoded": true
    }
 },
   "metadata": {
        "L2hvbWUvbmF3YQ==": "/home/folder1"
    },
    "recurrence": {
      "frequency": "Second",
      "interval": 15
    },
    "type": "ApiConnection"
  },
"When_a_file_is_added_or_modified_folder1_sub": {
    "inputs": {
      "host": {
        "connection": {
          "name": "@parameters('$connections')['sftp']['connectionId']"
        }
      },
      "method": "get",
        "path": "/datasets/default/triggers/onupdatedfile",
        "queries": {
        "folderId": "L2hvbWUvbmF3YS9zdWIx",
        "includeFileContent": true,
        "inferContentType": true,
        "queryParametersSingleEncoded": true
      }
  },
    "metadata": {
      "L2hvbWUvbmF3YS9zdWIx": "/home/folder1/sub"
    },
    "recurrence": {
      "frequency": "Second",
      "interval": 15
  },
    "type": "ApiConnection"
 }
}

Thanks to Microsoft Azure support for additional info.

Jigar Sheth
  • 586
  • 2
  • 5
  • 21
0

We can create multiple starter triggers. Start with Recurrence action then add more than 1 triggers. See below image.

Multiple starter triggers in LogicApp

Hemant Chandurkar
  • 363
  • 1
  • 3
  • 14
  • It makes sense in your example with files, but, if we want to have a http listener and recurrence component as start triggers, it is not possible. – inblueswithu Oct 10 '18 at 15:50
  • this is not working(triggering) for me . Starter trigger is recurrence then child triggers are "when item is available" (SQL create). They are not firing even if new record has been inserted to the table. – RollerCosta Sep 19 '19 at 09:23
  • ok.. I tried this long ago (1 year)... Microsoft keeps updating services so not sure still this is solution or not. – Hemant Chandurkar Sep 24 '19 at 10:59