<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Move file on FTP site in Pipelines</title>
    <link>https://community.fabric.microsoft.com/t5/Pipelines/Move-file-on-FTP-site/m-p/4179808#M5534</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="794577" data-lia-user-login="OldDogNewTricks" class="lia-mention lia-mention-user"&gt;OldDogNewTricks&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Since it is not possible to issue FTP commands directly from the fabric, this can be solved by utilizing a custom activity in the data pipeline.&lt;/P&gt;
&lt;P&gt;Add a custom activity to the data pipeline that can run a script. This script will handle the FTP commands.&lt;BR /&gt;Write a script (e.g. Python) that connects to the FTP server and moves the processed files to the archive folder. Here is a basic example using Python and the ftplib library:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;from ftplib import FTP

def move_file(ftp, source_path, dest_path):
    ftp.rename(source_path, dest_path)

def main():
    ftp = FTP('ftp.yourserver.com')
    ftp.login(user='username', passwd='password')
    
    # List of files to move
    files_to_move = ['file1.txt', 'file2.txt']
    
    for file in files_to_move:
        source_path = f'/path/to/source/{file}'
        dest_path = f'/path/to/archive/{file}'
        move_file(ftp, source_path, dest_path)
    
    ftp.quit()

if __name__ == "__main__":
    main()
&lt;/LI-CODE&gt;
&lt;P&gt;Upload this script to a location accessible by your data pipeline. Configure the custom activity to run this script after the files are processed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Yilong Zhou&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;helps&lt;/I&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 27 Sep 2024 02:47:03 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-09-27T02:47:03Z</dc:date>
    <item>
      <title>Move file on FTP site</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/Move-file-on-FTP-site/m-p/4176746#M5531</link>
      <description>&lt;P&gt;I have the following use case.&amp;nbsp; I have an FTP where only internal network traffic is allowed and files are stored there every 15 minutes or so.&amp;nbsp; Once I process the files on the FTP I would like to MOVE the files to an Archive folder ON the FTP.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Because the FTP only allows internal network traffic, I am unable to reach it from Fabric via notebooks.&amp;nbsp; I already have python functions that I COULD use if I could access from Fabric.&amp;nbsp; There is no IP range that I can provide to whitelist either, even if external traffic was allowed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can use a data pipeline to connect to the FTP and retrive the files through the data gateway, so that gets me halfway there.&amp;nbsp; However, I am unable to move the file using the FTP tool.&amp;nbsp; My only option is to leave the file or delete it when done.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I solve for this within a data pipeline?&amp;nbsp; Bascially I need to know how I can issue FTP commands within a data pipeline in a for each loop once the file successfully transfers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I KNOW we could change our process to either start storing these files directly on OneLake or maybe opening convert to an SFTP with a publiclly avaialble endpoint.&amp;nbsp; But I am trying to figure out how to use the tools within Fabric to solve this fairly simple usecase.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for any/all help!&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2024 06:07:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/Move-file-on-FTP-site/m-p/4176746#M5531</guid>
      <dc:creator>OldDogNewTricks</dc:creator>
      <dc:date>2024-09-26T06:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: Move file on FTP site</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/Move-file-on-FTP-site/m-p/4179808#M5534</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="794577" data-lia-user-login="OldDogNewTricks" class="lia-mention lia-mention-user"&gt;OldDogNewTricks&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Since it is not possible to issue FTP commands directly from the fabric, this can be solved by utilizing a custom activity in the data pipeline.&lt;/P&gt;
&lt;P&gt;Add a custom activity to the data pipeline that can run a script. This script will handle the FTP commands.&lt;BR /&gt;Write a script (e.g. Python) that connects to the FTP server and moves the processed files to the archive folder. Here is a basic example using Python and the ftplib library:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;from ftplib import FTP

def move_file(ftp, source_path, dest_path):
    ftp.rename(source_path, dest_path)

def main():
    ftp = FTP('ftp.yourserver.com')
    ftp.login(user='username', passwd='password')
    
    # List of files to move
    files_to_move = ['file1.txt', 'file2.txt']
    
    for file in files_to_move:
        source_path = f'/path/to/source/{file}'
        dest_path = f'/path/to/archive/{file}'
        move_file(ftp, source_path, dest_path)
    
    ftp.quit()

if __name__ == "__main__":
    main()
&lt;/LI-CODE&gt;
&lt;P&gt;Upload this script to a location accessible by your data pipeline. Configure the custom activity to run this script after the files are processed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Yilong Zhou&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;helps&lt;/I&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2024 02:47:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/Move-file-on-FTP-site/m-p/4179808#M5534</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-09-27T02:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: Move file on FTP site</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/Move-file-on-FTP-site/m-p/4181434#M5538</link>
      <description>&lt;P&gt;Yilong - I appreciate your suggestion, however I am not sure how to get this to work for the following reasons:&lt;/P&gt;&lt;P&gt;1. I do not have a custom script activity available.&amp;nbsp; I do see a script activity, but the only connections available are SQL based (Snowflake, SQL server, Azure SQL, Warehouse in Fabric).&amp;nbsp; I also see an Azure function activity, but I don't have any Azure functions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Even IF I could write a script and have the pipeline run it, I would not know how to ensure that the pipeline has access to it from Fabric.&amp;nbsp; Upload to OneLake and use from a Lakehouse?&amp;nbsp; Again, there are no connections avaialble that are NOT SQL based in the Script activity that I see in data pipeline&lt;BR /&gt;&lt;BR /&gt;3. The issue is that the FTP is only allowing internal network traffic, so even IF I could get a python script to load to a "Custom script" action, I cannot make the custom script use the data gateway to connect to the FTP.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help, I'm open to other options, but it does not appear this will work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At this point it seems like my options are the following:&lt;/P&gt;&lt;P&gt;1. Change our business process to either copy then delete the files from the FTP and keep in OneLake instead or leave the files on the FTP.&amp;nbsp; This is less than ideal to have to change a business process due to a simple limitation in the toolset that existing toolsets do not have any problems with today&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Write a pipeline that downloads and deletes the folder from the current source on the FTP then writes the file back to the archive destination in the FTP.&amp;nbsp; Obviously this is less than idea due to the extra CU we will incur and the extra time&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2024 05:45:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/Move-file-on-FTP-site/m-p/4181434#M5538</guid>
      <dc:creator>OldDogNewTricks</dc:creator>
      <dc:date>2024-09-27T05:45:46Z</dc:date>
    </item>
  </channel>
</rss>

