0
votes

Need to check a sftp site and there will be multiple files been uploaded to a folder. I am writing logic apps to process the files. Each logic app will handle one file because each file format is different. Problem is sftp trigger can only detect change to ANY file in the folder. So if a file changes, the logic app for that file will run, but OTHER logic apps will run as well which is not desired.

i have tried use recurrence trigger then followed by a sftp get file content by path action but that will fail if the file specified does not exist, what I want is the logic app just quit or better not been triggered at all.

How to just trigger the logic app if a particular file is updated/uploaded?

2
Why don't you put the conditions like if,else based on your file extension ? So that your specific logic can be run only if those conditions meet. Let me know If I want to elaborate as an answer..Jayendran
They are all csv files. i have tried put a condition after the sftp trigger and put filename = 'target file'. First problem is it never evaluates to true. The other problem is I want the rest steps to follow the true branch only but in logic app it seems i can only put a action inside the true or false box.thotwielder
Why don't you check the condition of the file extension rather than file name ? (Assume you multiple files having different extensions)Jayendran
They are all csv files.thotwielder
Have you solved this problem?George Chen

2 Answers

1
votes

On your logic App you can actually use the Dynamic Content and Expressions to do the following

decodeBase64(triggerOutputs()['headers']['x-ms-file-name-encoded'])

Hope it helps!

1
votes

I tried my Azure web FTP site with a condition if file name is equal to abc.txt and get the same Input. The Expression result is always false.

Then I check the Run Details I found the file name in OUTPUTS wasn't abc.txt, it's encrypted with base64.enter image description here

In my test abc.txt was encrypted into YWJjLnR4dA==, then I changed the file name to YWJjLnR4dA== in the Logic App condition and it works.

So you could go to check your run history get the file name or you could go to this site encrypt you file name with Base64.

Hope thhis could help you, if you still have other questions, please let me know.