ADF - Copy and delete files from File Storage to Storage Account

Rajesh Ambakkat 236 Reputation points
2023-06-21T15:15:18.4966667+00:00

i am trying to copy files from Azure File Storage to Blob storage(Archieve tier) using ADF. I also need to delete the files in source once copy is done. Same source file hierarchy (multiple folders in source) should be maintained at destination too while copy.

Using ADF copy activity i am able to do everything except delete files. How do i delete the files from source once copy is done, is there an option. I need to only delete the source file which is successfully copied.

Instead of copy activity do i have to use any other option? Please help

also i need to copy only files which are not updated since last 60 days...so how do i filter only files while copy?

Azure Files
Azure Files
An Azure service that offers file shares in the cloud.
Azure Storage
Azure Storage
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
{count} votes

Accepted answer
  1. Subashri Vasudevan 11,306 Reputation points Volunteer Moderator
    2023-06-22T05:04:17.6633333+00:00

    Hi @RajNa

    Thanks for using the MS Q&A Portal and for the question.

      1. Using ADF copy activity i am able to do everything except delete files. How do i delete the files from source once copy is done, is there an option. I need to only delete the source file which is successfully copied.
      • Copy activity does not have the ability to delete files after copying.. It is data flow which has the option to delete source file or move it a folder upon successful copy. But copy activity is cheaper than data flow. What you can do now is, you can use another copy activity to copy the files to archive and then a delete activity to delete the file after 2nd copy (to archive) is successful.
    1. also i need to copy only files which are not updated since last 60 days...so how do i filter only files while copy?
    • You can make use of a get meta data activity and use the last modified date option there to pick the files which were last modiefied 60 days ago. Please find below screenshot, where in my case, i am filtering files older than 10 days. I have four files in Azfs container, out of which just two files were last modified 10 days ago.

    Screenshot 2023-06-22 at 10.29.47 AM

    Screenshot 2023-06-22 at 10.30.59 AM

    Expression used

    @addDays(formatDateTime(utcNow(),'MM/dd/yyyy'),-10) : Start time UTC
    @formatDateTime(utcNow(),'MM/dd/yyyy') : End Time UTC
    
    
    

    Set variable is optional, if you want to see how the expression works, you may assign the above expression and see how it brings date.

    My output after execution

    Screenshot 2023-06-22 at 10.33.39 AM

    Hope it helps.

    Please let us know for any question.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.