How to delete a sub folder by using adf

Zhu, Yueli YZ [NC] 235 Reputation points
2024-03-05T15:43:04.65+00:00

Hi,

flowing is a path for a parquet file in a azure gen2 and the container is data:

data/hello/test/hello.parquet

I am able to use delete activity to delete the hello.parquet file but is there anyway that I can also delete the folder test.

Thanks

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

Accepted answer
  1. Amira Bedhiafi 23,251 Reputation points
    2024-03-05T16:37:37.7766667+00:00

    3 majors steps to follow in your case :

    1. Get Metadata Activity Configuration

    • Dataset: Point to your Azure Data Lake Storage Gen2 dataset
    • Field list: Choose the "Child Items" property to get the list of files and subfolders in your folder

    2. ForEach Activity Configuration

    • Items: Use the output of the Get Metadata activity, which is a list of child items. This will typically be an expression that looks something like @activity('Get Metadata Activity Name').output.childItem

    3. Delete Activity Configuration Inside ForEach

    • Dataset: Same as above, but the file path should be dynamically set based on the current item in the ForEach loop. You'll likely use an expression that concatenates the folder path with the name of the current item
    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.