Automatically delete Blob files in Azure based on future date
A blob is never going to remove itself. It would be contrary to the consistency and reliability of Azure if objects began to delete themselves.
The simplest thing I can think of would be to create a WebJob to monitor your storage account and delete blobs set for a few days. Or, if you store blob metadata in your application database, you can run a WebJob into your database and delete any blob where the deleted file is today.
WebJobs can, if your site is not under any real pressure, can be deployed in an existing WebApp process at no additional cost. If you expect your WebApp or WebJob to be particularly busy, I would consider splitting them up so they don't compete for resources.
There is a great blog post here that tells you everything you need to know to get started with WebJobs.
It's worth noting that a WebJob can run continuously, on demand, on a specific schedule, and in response to message queues or a file that gets deleted into memory storage.
source to share
1) In the future, it is not possible in Microsoft azure to automatically delete blob file by putting date or time in our box.
2) To achieve your goal, you create a small application, this application can be:
- Azure worker role
- Just a desktop application;
- Something else (like an asp.net app, or even an app written in Go).
The application logic is pretty simple:
- Check the drops every
N
seconds and remove those that match the reqirements (TTL completed). - You can use blob attributes or write to blob (or some other mechanism) for storage
born time (BT)
. - You can write to blob or make it permanent in your program (or use another mechanism) for storage
TTL
. - When you check the blob you should do:
(Current Time - BT) > TTL
and if it is "true" you can delete the blob
source to share