Azure storage account Life cycle management Policy not working at container level

Pratim Das, Partha C 346 Reputation points
2025-01-28T06:42:43.7833333+00:00

Hi Team,

I'm trying to delete any block blob from a specific container whose last modified date date is one day old. I'm using Storage account Lifecycle Management to accomplish that.

When I tested with "container name/blob's first letter" e.g. "mycontainer/a" it is working fine. But when I 'm applying it for all the blobs within a container e.g."mycontainer/" it is not working.

In my case my container name is "abcd" and policy code is

==============

{
  "rules": [
    {
      "enabled": true,
      "name": "delete 1 day old",
      "type": "Lifecycle",
      "definition": {
        "actions": {
          "baseBlob": {
            "delete": {
              "daysAfterModificationGreaterThan": 1
            }
          }
        },
        "filters": {
          "blobTypes": [
            "blockBlob"
          ],
          "prefixMatch": [
            "abcd/"
          ]
        }
      }
    }
  ]
}

==============

But after one day the aged blob still persists.

User's image

I can confirm policy was enabled before uploading the blob into the container. Please help.

Regards,

Partha

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
3,118 questions
{count} votes

Accepted answer
  1. Manu Philip 20,101 Reputation points MVP
    2025-01-28T07:57:27.9966667+00:00

    Hi Pratim Das, Partha C

    Please note that, your recently created/modified rules can take up to 24 hours to 48 hrs for actions to run the first time and to complete it.

    See the reference below:

    I created a new policy. Why do the actions not run immediately?

    Hope this helps.


    --please don't forget to upvote and Accept as answer if the reply is helpful--


1 additional answer

Sort by: Most helpful
  1. Sathvika Reddy Dopathi 225 Reputation points Microsoft External Staff
    2025-01-28T10:55:08.91+00:00

    Hi @Pratim Das, Partha C,

    Thank you for reaching out Microsoft Q&A Forum. 

    Azure Storage Lifecycle Management only applies policies to blobs that match a specific prefix, and does not support wildcard paths such as mycontainer/. If you want to delete all blobs in a container, you'll need to specify a prefix, like mycontainer/a.

    Lifecycle management policies generally take up to 24 hours to apply after they're created or updated. This delay occurs because the policy runs on a scheduled basis, and it doesn’t take immediate effect. If you've just applied the policy, waiting a bit for it to run could resolve the issue.

    The prefix filter in the lifecycle policy should match the beginning of the blob names. If your filter is set to something like "abcd/", the policy will apply only to blobs whose names start with this prefix (e.g., abcd/xyz).

    Please check the below code:

    {
      "rules": [
        {
          "enabled": true,
          "name": "delete 1 day old",
          "type": "Lifecycle",
          "definition": {
            "actions": {
              "baseBlob": {
                "delete": {
                  "daysAfterModificationGreaterThan": 1
                }
              }
            },
            "filters": {
              "blobTypes": [
                "blockBlob"
              ],
              "prefixMatch": [
                "abcd"
              ]
            }
          }
        }
      ]
    }
    

    For additional information please refer this link:
    Azure Blob Storage frequently asked questions

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

    Please consider to “up-vote” wherever the information provided helps you, this can be beneficial to other community members.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.