How does blob deletion works lifecycle management policy?

2024-04-22T10:59:45.9766667+00:00

Hi team,

I wanted to understand on how blobs are getting deleted through lifecycle management policy?

I created a policy to delete blobs using below code in 2 scenarios in which I changed

  1. "daysAfterCreationGreaterThan" as 1 and
  2. also "daysAfterCreationGreaterThan" as 0.0034

In the first case blobs are deleting approx. to 2 days, where the creation of blobs time is different but deletion of all blobs on that day is at same time.

In the second case few blobs got deleted after 1 hour but the remainig blobs are not yet deleted.

Please help me understand the flow of blob deleteion, also if there is any specific time during which a blob gets deleted in a day.

{
  "rules": [
    {
      "enabled": true,
      "name": "DeleteExpiredBlobs",
      "type": "Lifecycle",
      "definition": {
        "actions": {
          "baseBlob": {
            "delete": {
              "daysAfterCreationGreaterThan": 0.0034
            }
          }
        },
        "filters": {
          "blobTypes": [
            "blockBlob"
          ]
        }
      }
    }
  ]
}
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,436 questions
0 comments No comments
{count} votes

Accepted answer
  1. Amrinder Singh 2,195 Reputation points Microsoft Employee
    2024-04-22T16:22:08.5666667+00:00

    Hi Peddipathy, Erashree U [External/SLK Software] - Thanks for reaching out over Q&A Forum.

    LCM policy executes once a day as part of background scheduling option, but exact timelines aren't available. Once the policy triggers, whatever matches the rule configuration set, the action will be performed over those blobs. For the very first run it can take up to 24 - 48 hours but after that the results will be seen once in 24 hours.

    Also, the values need to an integer value and the same is documented in the below link as well.

    https://learn.microsoft.com/en-us/azure/storage/blobs/lifecycle-management-overview#rule-actions

    daysAfterCreationGreaterThan Integer value indicating the age in days The condition for actions on the current version or previous version of a blob or a blob snapshot
    daysAfterCreationGreaterThan Integer value indicating the age in days The condition for actions on the current version or previous version of a blob or a blob snapshot

    So, the only reason for deletion of some of the blobs will be few of the blobs matching the filter criteria.

    Please let us know if you have any further queries. I’m happy to assist you further.    


    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. TP 76,686 Reputation points
    2024-04-22T13:14:59.51+00:00

    Hi,

    I believe daysAfterCreationGreaterThan must be non negative integer (0 or positive whole number). I say this because a) the portal doesn't allow fractional numbers for this value and b) all of the documentation/examples I've seen show whole numbers and c) a fractional value would only make sense in very limited case since rules only execute once per day.

    As mentioned, policy only executes once per day, and you do not have control over the time of day they execute.

    With the above in mind, I'm unsure why it behaved the way it did for your second case (.0034). It could be a bug in that it specifying fractional numbers is unexpected and the code doesn't properly handle it.

    https://learn.microsoft.com/en-us/azure/storage/blobs/lifecycle-management-overview#lifecycle-policy-runs

    Please click Accept Answer and upvote if the above was helpful.

    Thanks.

    -TP

    0 comments No comments