Automatic delete of old Azure Blob Container Versions

Oliver Ziegler 20 Reputation points
2024-04-03T07:57:56.8766667+00:00

Hello, i have a problem/question.
We have setup an Azure Blob Storage and Store there some data in containers. We also have enabled versioning and soft-delete 14days.
User's image

Also we have setup lifecycle managment:

{
  "rules": [
    {
      "enabled": true,
      "name": "DeletePreviousVersions (auto-created)",
      "type": "Lifecycle",
      "definition": {
        "actions": {
          "version": {
            "delete": {
              "daysAfterCreationGreaterThan": 15
            }
          },
          "baseBlob": {
            "delete": {
              "daysAfterModificationGreaterThan": 14
            }
          },
          "snapshot": {
            "delete": {
              "daysAfterCreationGreaterThan": 14
            }
          }
        },
        "filters": {
          "blobTypes": [
            "blockBlob",
            "appendBlob"
          ]
        }
      }
    },

But the old versions won´t delete automatically. What is wrong with our configuration? I dont get it.... Do you have any idea?
User's image

Thanks in advance.

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,639 questions
0 comments No comments
{count} votes

Accepted answer
  1. Amrinder Singh 4,670 Reputation points Microsoft Employee
    2024-04-03T16:55:53.68+00:00

    Hi @Oliver Ziegler - Thanks for reaching out over Q&A Forum.

    Based on the snippet that you have provided; I could see that the blob is of type Page Blobs however LifeCycle Management policy is only supported for block blobs and append blobs. That seem to be potential issue in here:

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

    You can test this by creating some version of blockblobs type with a short period just for isolation.

    Now, if this is limitation due to Page Blobs, below are the options to explore ahead:

    You can try converting page blobs to block blobs and then let them get processed via LCM.

    https://learn.microsoft.com/en-us/azure/storage/blobs/convert-append-and-page-blobs-to-block-blobs?tabs=azure-powershell

    Alternatively, you might need to explore other options such as Logic app solution to delete these version irrespective of blob type.

    Please let me know for any further queries and will be glad to assist.

    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.

    1 person found this answer helpful.

7 additional answers

Sort by: Most helpful
  1. Anand Prakash Yadav 7,780 Reputation points Microsoft Vendor
    2024-04-03T09:37:05.4966667+00:00

    Hello Oliver Ziegler,

    Thank you for posting your query here!

    Your Azure Blob Storage lifecycle management policy appears to be correctly configured. However, there are a few factors to consider when troubleshooting why the Azure Blob Storage Lifecycle Management is not working.

    · The rule you shared specifies that the blob should be deleted if it has been modified for more than 14 days ("daysAfterModificationGreaterThan": 14). Ensure that the blob you are testing with has been modified more than 14 days ago.

    · The lifecycle rule is configured with a filter ("blobTypes": ["blockBlob", "appendBlob"]). Ensure that the blob types you specified match the actual types of the blobs you want to be deleted.

    · Make sure If you are updating or new policy it may take up to 48Hrs to complete.

    · Please note that if the blobs are created before the creation of the lifecycle management rule they will not be deleted.

    · Also check if any restriction is applied to a container or blob like Immutablity policy and the blob is leased.

    · If blobs in your storage account have previous versions or snapshots, then you should select Base blobs, Snapshots, and Versions in the Blob Subtype section when you are specifying a delete action as part of the policy.

    If everything is correct but still not being deleted, you can debug your storage account by using audit logs and if you get warning that will explain why the policy is not working.

    Please refer the following post on similar query: https://learn.microsoft.com/en-us/answers/questions/1282997/azure-blob-storage-life-cycle-management-not-worki

    I hope this helps! Please let me know if the issue persists or if you have any other questions.

    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.


  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  3. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  4. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more