ADLS Folder Deletion Issue in ADF Pipeline

Jake Atkins 20 Reputation points
2025-03-31T16:13:50.39+00:00

I am encountering an issue while creating a pipeline in Azure Data Factory (ADF) to delete folders in Azure Data Lake Storage (ADLS). The pipeline includes a 'Get Metadata' activity to retrieve a list of folders to delete, but it fails with the following error:

Failed to execute delete activity with data source 'AzureBlobFS' and error 'Operation returned an invalid status code 'Conflict''. For details, please reference log file here.

The pipeline fails at the 'Delete Files' activity. Here are the details of the pipeline configuration:

  • The 'Get Metadata' activity uses a binary ADLS Gen 2 dataset with the 'childitems' argument and is filtered by last modified time using the expression @{addminutes(pipeline().TriggerTime, -10)}.
  • Filter:
    • Items: using expression @activity('Get List of Files').output.childItems
      • Condition: using expression @and(equals(item().type, 'Folder'), not(contains(item().name, 'FOLDER NAME'))).
      • For Each:
        • Sequential = OFF
          • Items: using expression @activity('Filter Files').output.value
            • Activities: Delete Files
            • Delete Files:
              • Same binary dataset as above
                • Dataset directory set, Filename set using expression @item().name
                  • File path type: Currently set to 'File path in dataset', but I have tried different options, including wildcard, with the same issue.
                    • Recursively: ON

The pipeline fails when attempting to delete the targeted folders. Any insights on what might be causing this conflict would be greatly appreciated.

Below is a screenshot of the pipeline:

User's image

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

1 answer

Sort by: Most helpful
  1. Suwarna S Kale 3,391 Reputation points
    2025-03-31T18:32:11.1466667+00:00

    Hello Jake Atkins,

    Thank you for posting your question in the Microsoft Q&A forum. 

    The "Conflict" (HTTP 409) error in your ADF pipeline occurs when the Delete activity fails to remove folders from Azure Data Lake Storage (ADLS) Gen2. This must be happening due to one of the following reasons: 

    1. Folder Not Empty & Recursive Delete Not Working 
    • The "Conflict" error usually means ADLS Gen2 cannot delete a non-empty folder unless Recursive = true is explicitly set. 

    Even if you enabled Recursive Delete, there might be: 

    • Open file handles (leases) are preventing deletion. 
    • Permission issues (RBAC or ACLs blocking deletion). 
    • Concurrent modifications (another process modifying files while deletion is attempted). 

    2. Incorrect Path Resolution in Delete Activity 

    If the dataset path and item().name are not correctly combined, ADF may attempt to delete an invalid path. 

    Example Issue: 

    • Dataset path: container/folder/ 
    • item().name: subfolder/ 
    • Expected path: container/folder/subfolder/ 
    • Incorrect path: container/folder/subfolder (missing trailing / for folders). 

    3. Time-Based Filtering Race Condition 

    • Your filter uses @addminutes (pipeline().TriggerTime, -10), which may exclude recently modified folders that are still being written to. 
    • If another process (e.g., Synapse, Databricks) is actively writing files, ADLS may block deletion. 

    You may need to verify the below configurations to resolve the issue: 

    1. Ensure Recursive Delete is Properly Configured (test manually first) 
    2. Correct Path Format for Folders (trailing / for folders) 
    3. Add Error Handling & Retry Logic 
    4. Check Permissions - ADF Managed Identity must have Storage Blob Data Owner (RBAC) or Execute + Write + Delete (ACLs) on the folder 
    5. Test with a Simpler Pipeline - Try to delete one known empty folder first 

     

    Some Microsoft documentation may help to learn more about the above pointers: 

    https://learn.microsoft.com/en-us/azure/data-factory/delete-activity 

    https://learn.microsoft.com/en-us/azure/data-factory/data-factory-troubleshoot-guide  

    https://learn.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/delete?view=rest-storageservices-datalakestoragegen2-2019-12-12#status-code-409  

    https://learn.microsoft.com/en-us/azure/storage/blobs/data-lake-storage-directory-file-acl-powershell#delete-directories  

     

    If the above answer helped, please do not forget to "Accept Answer," as this may help other community members refer to the information if they face a similar issue. Your contribution to the Microsoft Q&A community is highly appreciated. Thank you for posting your question in the Microsoft Q&A forum. 


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.