question

MB69 avatar image
0 Votes"
MB69 asked ·

Azure Logic App: FTP conditional file management

Hello,
I am trying to create a logic app that can manage my ftp server. We have multiple vendors dropping files on our ftp server. Based on the prefix of the file, I would like to move it to a specific folder and strip the prefix/suffix once moved.

What would be the best way to tackle this? Also, would I have to create multiple conditions based on each vendor and suffix or can I create a reference for each vendor in a list/table?

azure-logic-apps
· 1
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @MB69 - Sorry for the delay in our response. We are now actively investigating and will answer with our findings soon.

0 Votes 0 ·

1 Answer

MikeUrnun avatar image
0 Votes"
MikeUrnun answered ·

Hello @MB69 There are multiple ways to implement this workflow using the SFTP - FTP connector depending on how frequently the files are uploaded and how big the file sizes are. I've put together the following workflow as a quick demonstration in hopes that it'll give you some ideas and get you started:


9750-murnuncxp.jpg


A few noteworthy items regarding this workflow are as follows:


Trigger uses base64 encoding for keeping the data intact so be sure to use base64ToString() function to decode the data wherever needed.


The vendor list is stored in an array collection: vendorCollection


The vendor name is extracted from the trigger with @{split(base64ToString(triggerOutputs()['headers']['x-ms-file-name-encoded']), '_')[0]} and set as a value for the vendorName variable for reusability across subsequent actions.


Condition check whether vendorName exists in the vendorCollection array. If true, workflow continues on to copy the file to a folder matching vendorName value and renames it with vendorName followed by deleting the original file that was uploaded.


Condition to check is as follows: @contains(variables('vendorCollection'), variables('vendorName'))


RunAfter is configured across "Copy File", "Rename File" and "Delete File" actions so that they run one after the other sequentally


In my example workflow above, I only strip the prefix which is assumed to be the matching vendor name but you can make slight adjustments to it for any desired format -- let me know if any further assistance is needed ;)



murnuncxp.jpg (160.0 KiB)
·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.