Can an Azure Logic application have multiple start triggers?

Can an Azure Logic application have multiple start triggers?

I have read the triggers docs on MSDN but I don't see anything when there are multiple triggers

+4


source to share


5 answers


In general, yes, there can be multiple triggers in a logic app workflow . In fact, according to the official documentation , there can be up to 10 triggers in one logic app. For example, in the following logic app, I used two triggers, the first is an SFTP connector trigger, and after a sequence of actions, I have a second trigger on the Service Bus queue (with a send message action, I send a message to a web job that does a long term task and notifies the logic app has a message on another queue that allows it to continue executing).



enter image description hereWhat you probably mean instead is, if it is possible to have multiple "trigger" triggers to implement some "or logic" between triggers. In this case, I think the answer is no, and in order to achieve this, I will also use what @Steven Van Eycken suggests: split logic apps into two of them, fired by the two necessary triggers, and for example then send a message to a queue that launches a third logic app with a shared workflow.

+7


source


I guess I was a little late to the party, but I managed to create some triggers for the logic app.

In my case, I am using an SFTP connector to start when a file is created or modified. The SFTP connector only allows one folder to be monitored, but I didn't want to duplicate the logical app for every folder I want to monitor, so I 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 go back to the design view, but essentially I set up my logic app the way I wanted it, then went to the code view, duplicated the trigger definition and changed the bits I need to change (name, folder name and folder id).



The trigger history in the Overview screen allows you to choose which trigger you want to see, but whichever trigger fires, the rest of the logic app works. You also lose the ability to see a view of the historical runs workflow, but with a few extra clicks you can see what is happening at each stage of the application.

This is a pain that can only be done in code, but it is possible, of course, with the same type of trigger. I'm not sure about mixed trigger types, but I think as long as you don't rely on getting out of one that doesn't exist in others, then it should be fine. I also tested it with multiple email triggers. Just keep in mind that if the connectors require different connections, you will need to include each of the connections in your code. To begin with, one could build each in a separate application, and then insert the appropriate bits of code.

+1


source


This answer is a continuation of @ Steve's answer. Steve explained how this can be done, I'm just going to add a code snippet for clarity.

Also, when I tested this solution, it didn't work for me in the second folder in the trigger list by clicking Run from the code view. Because I think "Run" by default fires the first trigger. So for testing purposes, I've set the startup time to 15 seconds, so it's easier to test it 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"
 }
}

      

See Microsoft Azure support for more information.

+1


source


We can create multiple starter triggers. Start with a Repeat action, then add more than 1 triggers. See the image below.

Multiple starter triggers in LogicApp

0


source


Can't comment, but I tried to get Hemant's answer to work. Have the same setting. Multiple SFTP folders that need to be monitored all produce the same logical flow upon startup. Basically, I just need to write to my database so that I can create queues to move files to blob storage (my files are over 50MB, so this can't be done in a logic app).

I ran into a problem with this method. I just need to get the metadata. I will keep trying this.

Here is my problem, re-trigger fires, SFTP trigger fires. There is some overlap because the repeat trigger still fires when the next one fires.

enter image description here

0


source







All Articles