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
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
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).
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.
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.
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.
We can create multiple starter triggers. Start with Recurrence action then add more than 1 triggers. See below image.