Disable soft delete for blob and containers in storage account registry module

I can see that from terraform document there is no direct parameter to disable soft delete for azure storage account. If I wanted to set container_delete_retention_policy to 0, I can’t do since Azure doesn’t allow to set 0. Is there any way that I can disable soft delete for storage account through terraform. Is there any way I can use lifecycle management to do this, but would require some additional info for this.
Thanks in advance.

As this is not supported by the AzureRM provider you have a couple of options.

Firstly (and my preferred approach) is to create the storage account as normal using the AzureRM provider. Then use the azapi_update_resource from the AzApi provider to ‘patch’ the relevant resources’ properties that are not supported which would be the containerDeleteRetentionPolicy and the deleteRetentionPolicy properties in the Microsoft.Storage/storageAccounts/blobServices
Ensure you are referencing the AzureRM resource in the AzApi resource block in order to ensure there is an implied dependency. e.g.:

resource_id = azurerm_storage_account.example.id

Additionally, you may need a lifecycle ignore_changes block in your azurerm_storage_account resource if the change that the azapi resource makes is visible to the azurerm resource and causes a perpetual apply being needed if the plan sees the resource as being changed.

The second way is to use the AzAPI azapi_resource and create the storage account and services directly. This is typically more complex.

Note that when using the azapi provider the current version supports Dynamic Properties which provide benefits when it comes to plan time and change detection - the Microsoft Learn examples have not been updated to reflect this and still show the jsonencode() which is no longer required.

Hope that helps!

Happy Terraforming