how to configure property to delete versions after certain days for storage account using terraform

HJ 0 Reputation points
2023-09-12T10:06:17.8366667+00:00

I could enable versions in storage account using below terraform code. but I dont see any option to enable the property to delete versions after X number of days as it reflects on portal. can we do this using terraform? If not, whats the alternative way to do this?

blob_properties {  versioning_enabled         = true}

All the time duration and retention related properties available on portal seem to be related to soft delete -> https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account#delete_retention_policy , Whereas I want to achieve below thing and that too using terraform (refer to "Delete Version after"):

User's image

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

1 answer

Sort by: Most helpful
  1. Wilko van de Velde 2,236 Reputation points
    2023-09-12T10:42:37.98+00:00

    Dear HJ,

    You should be able to add delete_retention_policy to the blob_properties block.

    More information:
    https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account#delete_retention_policy

    Kind regards,

    Wilko


    Please do not forget to "Accept the answer” wherever the information provided helps you, this can be beneficial to other community members. If you have extra questions about this answer, please click "Comment".


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.