Azure data factory: Delete activity doesnt work as expected

Tomas Hudik 21 Reputation points
2023-02-19T14:50:49.9133333+00:00

Hi there,

I need to delete old files. Toy example: on azure data storage I have created a bunch of files (notice Modified field):

User's image

my Delete looks like:

User's image

so - delete files created 4 hours ago (original files were created some 10 min ago). However when I run it Delete passed successfully but delete 0 files I got:

User's image

Any idea what is wrong?

(I have followed: http://datanrg.blogspot.com/2019/03/delete-activity-in-azure-data-factory.html )

thx, Tomas

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

Answer accepted by question author
  1. KranthiPakala-MSFT 46,737 Reputation points Microsoft Employee Moderator
    2023-02-20T21:08:14.4+00:00

    Hi @Tomas Hudik ,

    Welcome to Microsoft Q&A forum and thanks for reaching out here.

    Appreciate much for sharing the configuration screenshots which helped to reproduce and identify the issue.

    Potential Problem: When we use Filter by last modified property, the files with last modified time in the range [Start time, End time] will be filtered for further processing during the activity run. But as per the image you have shared, seems like you are passing only the end time but not the start time for the last modified range which is why no files are being deleted. I was able to reproduce the issue by only configuring the end time but not the start time and 0 files were deleted.

    When I provided both start time and end time range for the filter by last modified, expected files were deleted as per the defined range.
    Hence, please enter start time of the filter by last modified to something like @addToTime(utcnow(), -20, 'Year') (Please note, you can modify the year number as per your need. This is just an example for reference) and End time to @addhours(utcnow(), -4) and it should work as expected.

    User's image

    Result: User's image

    Hope this helps. Please do let us know if you have further questions.


    Please don’t forget to Accept Answer and Yes for "was this answer helpful" wherever the information provided helps you, this can be beneficial to other community members.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Subashri Vasudevan 11,306 Reputation points Volunteer Moderator
    2023-02-19T14:59:50.9333333+00:00

    Hi @Tomas Hudik

    If you want to delete files which are modified 4 hours ago, use the below expression in last modified field

    addhours(utcnow(),-4)


Your answer

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