admin管理员组

文章数量:1406150

I have recently configured my Azure Blob Container using terraform to delete the Container after delete_after_days_since_creation_greater_than=1 officially as per the terraform Azure provider it should delete the container data after after 1 i.e 24 hours but I'm observing that it deletes aftr 48 hours is this issue expected?? Below i am attaching the code.

resource "azurerm_storage_management_policy" "azurerm_storage_blob_deletion" {
  storage_account_id = azurerm_storage_account.load_service_blob_storage.id

  rule {
    name    = "Rule For Deletion of Blobs"
    enabled = true
    filters {
      prefix_match = ["${azurerm_storage_container.load_service_blob_container.name}"]
      blob_types   = ["blockBlob", "appendBlob"]
    }
    actions {
      base_blob {
        delete_after_days_since_creation_greater_than = 1
      }
      snapshot {
        delete_after_days_since_creation_greater_than = 1
      }
    }
  }
}

I have recently configured my Azure Blob Container using terraform to delete the Container after delete_after_days_since_creation_greater_than=1 officially as per the terraform Azure provider it should delete the container data after after 1 i.e 24 hours but I'm observing that it deletes aftr 48 hours is this issue expected?? Below i am attaching the code.

resource "azurerm_storage_management_policy" "azurerm_storage_blob_deletion" {
  storage_account_id = azurerm_storage_account.load_service_blob_storage.id

  rule {
    name    = "Rule For Deletion of Blobs"
    enabled = true
    filters {
      prefix_match = ["${azurerm_storage_container.load_service_blob_container.name}"]
      blob_types   = ["blockBlob", "appendBlob"]
    }
    actions {
      base_blob {
        delete_after_days_since_creation_greater_than = 1
      }
      snapshot {
        delete_after_days_since_creation_greater_than = 1
      }
    }
  }
}

Share Improve this question edited Mar 7 at 12:41 Vinay B 2,8242 gold badges3 silver badges12 bronze badges Recognized by Microsoft Azure Collective asked Mar 6 at 11:36 ptc-sharwalkarptc-sharwalkar 11 bronze badge 1
  • Azure Storage lifecycle policies operate asynchronously, so while delete_after_days_since_creation_greater_than = 1 makes blobs eligible for deletion after 24 hours, actual deletion may take up to 48 hours; refer to Azure Storage lifecycle management refer: learn.microsoft/en-us/azure/storage/blobs/… – Vinay B Commented Mar 6 at 13:27
Add a comment  | 

1 Answer 1

Reset to default 0

Deletion of Blob Container not deleting after 1 day

In this type of behavior we have nothing to do with the terraform script as it was the functioning property of the policy lifecycle management of blob file.

The property `delete_after_days_since_creation_greater_than` is designed in such a way that automate the deletion of blobs after a specified number of days. However, when this timing may vary as per some factors.

If you're recently create or modify the rule, It can take up to 24 hours for actions to run the first time and up to 48 hrs to complete if the policy was updated. It also occurs in the first since it was first time creating of policy. The rule you have created is only for the Block blobs and Append blobs. Double check that the blobs you are seeing are not snapshots or versions and are indeed block blobs.

Since this policy is works in the background, which means the evaluation of blob existence was done after 24 hours and deletions may not occur immediately after the specified period.

This was due to asynchronous nature of policy enforcement sometimes soft deletion was available for blob which in result even after the deletion of blob it still shows up in the containers.

While using this property, make sure you enabled `last_access_time_enabled` so that policy has access to the last creation date of blob.

Refer:

https://learn.microsoft/en-us/azure/storage/blobs/soft-delete-blob-overview

https://learn.microsoft/en-us/answers/questions/2110500/azure-blob-lifecycle-management-rule-not-deleting answered by Hari Babu Vattepally

https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_management_policy#delete_after_days_since_creation_greater_than-1

本文标签: azureDeletion of Blob Container not deleting after 1 dayStack Overflow