How to configure lifecycle management for blobs differently?

Batchu Sai Akhil 1 Reputation point
2022-04-14T09:48:22.817+00:00

I am having 5 blobs (i.e 5folders) inside the container, I want to delete the 4 blobs after 30 days and other one after 90 days. So I created lifecycle management rule.

The blobs which I want to delete after 90days, I am identifying that one blob with tags (i.e While uploading folder to container I have added tags).

To satisfy the above conditions I have created two rules

Here is the rule:

{
    "rules": [
      {
        "enabled": true,
        "name": "rule1",
        "type": "Lifecycle",
        "definition": {
          "actions": {
            "baseBlob": {
              "delete": {
                "daysAfterModificationGreaterThan": 30
              }
            },
            "snapshot": {
              "delete": {
                "daysAfterCreationGreaterThan": 30
              }
            }
          },
          "filters": {
            "blobTypes": [
              "blockBlob",
              "appendBlob"
            ]
          }
        }
      },
      {
        "enabled": true,
        "name": "rule2",
        "type": "Lifecycle",
        "definition": {
          "actions": {
            "baseBlob": {
              "delete": {
                "daysAfterModificationGreaterThan": 90
              }
            }
          },
          "filters": {
            "blobIndexMatch": [
              {
                "name": "Folder",
                "op": "==",
                "value": "cvad"
              }
            ],
            "blobTypes": [
              "blockBlob",
              "appendBlob"
            ]
          }
        }
      }
    ]
  }

Can any one please assist/suggest me if I am doing correct or not? Here my doubt is when Rule:1 is executing I think it also delete all the blobs including the blob with tags as it got satisfied in first Rule

Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
2,944 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,639 questions
{count} votes

1 answer

Sort by: Most helpful
  1. 2023-03-31T19:15:25.33+00:00

    @Batchu Sai Akhil please find my answer for 2 questions,

    Q1. Here my doubt is when Rule:1 is executing I think it also delete all the blobs including the blob with tags as it got satisfied in first Rule

    Ans: Yes, the rule 1 check the last modified date directly in all containers/folders in storage account and its delete after 30 days from modified time due to not having any filters. so while the rule 2 running, it may not get any blob which is having last modified 90 days blobs

    Q2.I want to know how to exclude one particular blob and delete remaining all the blobs in the container.

    Ans: step-1: you have to differentiate that blob(90 days) with either Blob index match or blob prefix

    step-2: in rule1 you have to limit with filter set (bcoz the rule 1 checking only with 30days without filter)

    step-3: based on differentiate(step-1) you can set remaining filter (either Blob index match or blob prefix) for rule-2, if you not set filter also be the fine. due to rule1 already deleted expect your 90days blob.

    if you still have questions, please do let us know. Thank you!

    0 comments No comments