Automatically delete Blob files in Azure based on future date

I'm wondering if there is a way to automatically delete a blob file in the future in Microsoft azure by setting a future date or time? After the specified time, the blob file is automatically deleted. I am using C # ASP.NET.

+3


source to share


3 answers


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.

+1


source


There is no mechanism that can do this exclusively using blob memory.

https://feedback.azure.com/forums/217298-storage/suggestions/2474308-provide-time-to-live-feature-for-blobs



Of course, you can write a service that can query every blob and delete if the TTL is exceeded, which you could store in MetaData. You will receive a charge for every read and delete.

0


source


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
0


source







All Articles