Hi,
You can configure Azure storage LifeCycle policy to delete the file automatically.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
How to delete files older than XX days inside the Azure blob storage? I do not want to delete the blob but i want to delete the files inside. Thank you.
Hi,
You can configure Azure storage LifeCycle policy to delete the file automatically.
Hi @Leong, HoeySiang,
You can try to use Azure storage lifecycle policy to achieve this. Please find the link below where it is mentioned about lifecycle policy and steps to enable the same.
Hello Leong, HoeySiang,
Greetings! Welcome to Microsoft Q&A Platform.
To delete older files from each folder in Azure Blob Storage, you have a couple of options:
#1. Blob Lifecycle Management (Recommended): Azure Storage provides a feature called Blob Lifecycle Management. With this, you can define policies to automatically delete blobs based on criteria such as their age (e.g., older than 30 days). Go to your Azure Storage Account.Navigate to Blob Service > Lifecycle Management. Define a policy to delete blobs older than your desired threshold (e.g., 14 days). Azure Storage will handle the deletion for you.
#2. Azure Functions: You can create an Azure Function that periodically checks each folder and deletes files older than a specified duration. Here’s a high-level approach: Create a Timer Trigger function. Fetch the list of blobs from the corresponding Blob Container. Check the LastModified property of each blob. Delete the blobs that don’t meet your criteria (e.g., older than 14 days).
Remember to test any deletion process on a test folder first to avoid accidental data loss. Adjust the path and days as needed for each folder.
Hope this answer helps! Please let us know if you have any further queries. I’m happy to assist you further.
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.