How to delete previous day files in container once pipeline successful in ADF?

Anuganti Suresh 200 Reputation points
2024-02-29T15:42:06.42+00:00

I have container name input and folder path as yyyy/MM/DD. Currently i have folder structure like 2024 and inside that 2(FEB) and inside that has day wise folders 1, 2, 3, 4, 5 etc. I have pipeline (data ingestion & transformation) and runs on daily basis. On particular day once pipeline completed wants to delete previous source file in container. How to achieve this scenario?

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,548 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. HimanshuSinha-msft 19,471 Reputation points Microsoft Employee
    2024-02-29T22:44:07.5533333+00:00

    Hello @Anuganti Suresh, Thanks for using Microsoft Q&A .
    You should use the delete activity to achieve this. You will have to create the path dynamically (2023/2/1/*) and pass that as the path in the activity. https://learn.microsoft.com/en-us/azure/data-factory/delete-activity . You will also have to use the data and time function to get yesterdays date and then get the Year , month and day from that .
    https://learn.microsoft.com/en-us/azure/data-factory/data-flow-date-time-functions Thanks
    Himanshu


  2. Anuganti Suresh 200 Reputation points
    2024-03-02T12:43:53.26+00:00

    Below solution solved my query.

    User's image

    User's image

    0 comments No comments

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.