I'm using Azure-Storage for storing information like a cache mechanism. So, for given input I'm doing the job for first time and after that I'll save the result in the cache for further use. When I'll need to solve the problem with same given input, I'll get it directly the already ready solution from storage. This all is implemented.
I'm trying to add a expiry limit for file in my cache. Each result will be stored for maximum 30 days. After that, they will be automatically deleted.
The naive solution is to implement also an background worker that will run one time per day and will run over all files and delete them, according to their creation time.
There are better solution?
To enable blob versioning for a storage account in the Azure portal: Navigate to your storage account in the portal. Under Blob service, choose Data protection. In the Versioning section, select Enabled.
The default retention period is seven days, but you can retain data for up to a year. In any case, you will have to click the Save button when you are done, to complete the process of enabling Soft Delete.
The blob storage option is not persistent, as opposed to other Azure storage options like hard disks of Infrastructure-as-a-Service (IAAS) or VMs. As a result, you have to use persistent stores like tiers for long-term storage of files. There are three types of storage tiers.
We don't currently have automatic expiration for blob storage. To your point you could use something like WebJobs to run a background task to delete files. If you have a large number of files that you create each day a simpler approach could just be to create a new container each day and store the blobs created each day in that container - then each day you just delete the container that is 31 days old. You could also do something similar with Tables whereby you create a new Table each day - and then delete the Table that is 31 days old.
I landed here from Google, so I'm leaving this for future readers. Microsoft currently has Blob Storage lifecycle management in public preview.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With