How to automatically delete data in Azure without manual intervention


  • A DVR can store data for 15 days. On the 16th day, it adds the new data simultaneously deleting data from the 1st day. This happens in the FIFO manner. I want to understand how can we do such action on Azure Storage because as per my understanding we can add data on Azure but I don't know how we can delete data from Azure automatically without any manual intervention, so that we are not exceeding the 15 day storage limit. This means at any instance data captured in the last 15 days should be stored in azure.
    Saturday, August 6, 2016 6:36 PM

All replies

  • Hi Ravi,

    Thank you for posting here! We are happy to assist you. 

    If you are referring to Blob storage.

    Blob has no this kind of build-in properties/APIs. However, if you want to delete the blobs automatically, we need to write delete function in our work role we can
     use the container's ListBlobs method to fetch the blobs which has already existed 48hrs, then delete. For more information, you could refer to the below link: 

    A blob is never going to delete itself. That would contradict the consistency and reliability of Azure if objects started deleting themselves.
    The simplest thing to do that I can think of would be to set up a WebJob to monitor your storage account and remove blobs that are a specified number of days old. Or if you store metadata about a blob in your app database you could have the WebJob look into your database and delete any blob.

    If you're site isn't under any real pressure, be deployed to an existing WebApp process at no additional cost. If you expect either your WebApp or WebJob to be particularly busy I would consider separating them so they don't compete for resources.

    There's a great blog post here that tells you all you need to know to get started with WebJobs.

    It's worth noting that a WebJob can run continuously, on demand, on a defined schedule and in response to message queues or a file being dropped in blob storage.

    For complete information on Storage. Click here

    Sumanth BM

    Sunday, August 7, 2016 9:52 AM