Viswanath
Viswanath

Reputation: 59

Azure Block blob expiration through the application

Is there any way to set time to live attribute for the block blobs being uploaded to the azure blob container? I am using this method from the azure storage client library to upload the blobs.

I got a chance to try the lifecycle management option on the azure portal.

I would prefer to set the ttl property from the application since in the higher environments, I might not have access to the azure portal. Also, we would need to modify the ttl on the fly based on the needs.

Can this option be considered to set the ttl programmatically? I have tried this option cloudBlockBlob.getProperties().setCacheControl("max-age=70"); // 70 seconds after upload but it was not expiring.

Thanks in advance!

Upvotes: 2

Views: 689

Answers (1)

Gaurav Mantri
Gaurav Mantri

Reputation: 136196

I would prefer to set the ttl property from the application since in the higher environments, I might not have access to the azure portal. Also, we would need to modify the ttl on the fly based on the needs.

Specifying TTL at the blob level so that blob gets automatically deleted after TTL expiration is not supported in Azure Storage.

I have tried this option cloudBlockBlob.getProperties().setCacheControl("max-age=70"); // 70 seconds after upload but it was not expiring.

This essentially is an instruction for the agents like browsers to cache the content for certain amount of time and fetch the content from source again once that time period elapses.

Upvotes: 1

Related Questions