Tuesday, 8 October 2019

Azure Storage Blob : Policies

It has been a feature that was missing from Azure Storage Blob capabilities - adding policies for performing actions after certain conditions e.g. deleting a blob item after 1 month. 

There are typical use cases for it. I can give you one example.

Let's imagine an API that needs to asynchronously process messages it receives. An standard approach will be to put the message in a blob storage and leave a message in the queue with the address of blob item so that you can process the item later on.

Application's queue processor service can read the message, downloads the blob item and process the request. However, it might need to add a "maintenance" code to delete the blob item so that you don't store the unnecessary message. This is a code you could have avoided if platform had a feature for it :).

PS: if the message is smaller than 64kb than you can directly put it in a queue too, but we digress.


Well, Microsoft Azure Storage has added support for policies for handling typical actions (like the one i mentioned) for Azure Blob. Link

Quite nifty feature.

I can define a rule like below to delete items after 1 month.

{ "rules": [ { "name": "deleteTemporaryData", "enabled": true, "type": "Lifecycle", "definition": { "filters": { "blobTypes": [ "blockBlob" ], "prefixMatch": [ "queueinputblob/messages" ] }, "actions": { "baseBlob": { "delete": { "daysAfterModificationGreaterThan": 30 } } } } } ] }


No comments:

Post a Comment