Azure Logic App: FTP conditional file management

MB69 1 Reputation point
2020-05-28T14:26:58.987+00:00

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
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,845 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Mike Urnun 9,666 Reputation points Microsoft Employee
    2020-06-11T04:11:12.37+00:00

    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 ;)

    0 comments No comments