Why Does Azure Logic App Firing Twice For no Reason - azure

I have a Data Factory pipeline that perfroms some pretty simple tasks. For somereason, the Logic App portion of the pipeline is "firing" multiple times, even thouh I'm calling it just once.
So, the pipeline runs three stored procedures. It then exports the results to a Data Lake container. Then lastly, it send an email with the three reports as attachmentsin an email.
I have everything working fine, but there is one odd bit of behavior I'm seeing. The logic app is essentially firing three times when it's called, so I end up getting three emails. It looks like I'm doing everything right.
Logic App Designer
Logic App
I seems as though it's firing for each attachment / blob content action. I'm fresh out of ideas. If anyone has any thoughts, that would be awesome.
Thank you!

The trigger will be fired if you add/modify the files in the folder which you specified every x minutes(you set it 3 minutes). And if you added/modified three files, the trigger will be fired three times, so you received three emails. You can take a look the runs history of your logic app, every time running the "Body" of the trigger will return one file content of the three files.
If you don't want the flow run three three times, you can set the trigger by following steps below:
Change the "Number of blobs to return from the trigger" to 10 (or any number which you want, but should be greater 3 as you have three files).
Click the ... button at the upper right-hand corner of the trigger and click "Settings", disable "Split On".
After completing the two steps of setting, the "Body" of trigger will return all of the three files in one time, you will receive only one email.
Update:
Sorry for missing one step, apart from the steps above we also need to add a "If" condition in the logic app.
Create a "If" condition after the "When a blob is added or modified (properties only)" trigger, the details of the condition shown as below:
If true, do the steps what you want(such as get the blob content and send emails). If false, do nothing. Then you will just receive one email.
By the way, if you notice the run history, you can see the logic app was triggered two times. In first time, the trigger response the "body" with a [] array and in second time the trigger response the "body" with three blob array. This is why we need to add the "If" condition.

Related

Azure logic apps: Only attach file if condition met outlook v2

I am creating an automated email that sends everyday on a schedule. Within this 4 reports are created using individual sql queries that then generate csv files with essentially a list of names - all this works fine. When some of these are generated they are empty so I have used parallel branches to set a variable to true or false if the csv is created or not.
So at the end of this I have 3/4 files and a variable for each stating whether or not it has been created.
What I want to know is how do I only attach a file if a variable is true as if a null/not created csv is attached it errors.
Any additional information required just ask.
Thanks
What I want to know is how do I only attach a file if a variable is true as if a null/not created csv is attached it errors.
When you use parallel branches, each branch is executed regardless of whether the variable is true/false or if the file is created/not. In this case, you can use the Condition action instead of parallel branches where the email is sent only when the variable is true. Below is the flow of my Logic app.

ADF Storage event trigger when there are multiple files in different folders

I need to trigger my ADF pipeline when three files arrives in paths : container/folder1/file1.parquet
container/folder2/file2.parquet
container/folder3/file3.parquet
Only when these 3 subfolders gets new files(files will be overwritten) should the ADF pipeline trigger.
How can we achieve this?
Update : This should be an AND condition, ie - the pipeline should be triggered only after all 3 files arrive or gets updated.
Update:
There is no out-of-the-box feature to achieve this, you can share your idea here
What you can do is
Setup a Storage event triggered pipeline on first destination i.e. container/folder1/file1.parquet as I have explained earlier.
Then after maybe waiting for few secs using WaitActivity use Get Metadata activity with Field list
Argument as Child items to get list of files in the folder
or
LookupAcitivty chain to look for files at container/folder2/file2.parquet and container/folder3/file3.parquet with file list path property. File list examples
Then you can hold the results in variables for convenience and using Conditional activities like IfActivity compare to see if all the files exist, if True you can proceed with further activities you plan to design in the pipeline when the three files arrived.
In case of explicit availability or 3 files seperately..
You can simply use 3 different new triggers for same pipeline. Each with different folder as its Blob path ends with property in trigger.
Here is sample trigger for first folder i.e. container/folder1/file1.parquet
You can also mention like .parquet using patterns to match files with different names dynamically.
Note: That Blob path begins with and ends with are the only pattern matching allowed in Storage Event Trigger.
Similarly you can create 2 more for container/folder2/file2.parquet and container/folder3/file3.parquet

Triggering action if ONE specific file changes on SharePoint

Is there a way to trigger an action in Microsoft Flow (Power Automate) when just one specific file in SharePoint gets modified? At the moment I have the situation that 6 files are updated at once, so the same action is triggered 6 times in a row.
I use the trigger "When an item is created or modified". There I can only adjust the SharePoint site name and the list (library) of files to monitor.
Make sure your settings are set in a way the flow don't run in parallel.
In essence, you may want to limit the concurrence of the flow so it will run just once at a time.
1) First go to the settings
2) Limit the paralellism. If you just want to work on the first item then click turn on Split On which will yield a single file.
You can check here for more details.

What is the purpose of the "Number of blobs to return from the trigger" setting on the "when a blob is added or modified" Logic App trigger

The question is in the title however its not as clear cut as you may initially imagine.
From what I can tell a logic app is triggered once per blob regardless of what you set "Number of blobs to return from the trigger" to..
It does return a number of values called List of... but again they seem to be badly named single values with no way to enumerate them.
The docs offer no insight whatsoever.
What am I missing?
Suppose it's because the SplitOn is enabled by default. If this is enabled the triggerbody won't be a blob metadata array, it splits the array then each run it process one blob metadata.
If you want to use For each action, just disable the Spliton, or you could just do the actions without For each action.

Azure logic app with Condition

I am creating the logic app when I want to send an email when there are duplicate entries created in my database, and until those are not removed email should be triggered after some interval
As per Logic App, we can create a trigger on SQL when data is inserted or modified as bellow
So I selected the first option then I am adding another action which will run my SQL script to check the logic of duplicate entries
and last I have added another action to send an email.
Now I want my last action of sending email to be executed only when my query comes up with some result
You can use a Condition Control to check whether the given result set is valid if the condition satisfies then you can send the email
See my logic app below.
Here I've added the Execute a Stored Procedure Action. My stored procedure returns resultsets, you can use the logic for checking the duplicate and in the next condition you can check the duplicate result is true (or) false. If it's true you can send email else not to.
Update 1
How to Add condition control
I think you're better off programming the duplicate condition detection into a Stored Procedure rather than a SQL Trigger then using the Logic App change Trigger.
Instead, use a Logic App and Recurrence to call the Stored Procedure that queries for duplicates and returns the necessary meta data.
Trigger + table + change will be less reliable then you expect and much harder to maintain.

Resources