Description
Set purge_protection_enabled = true to keep soft-deleted keys, secrets and certificates recoverable throughout the retention period. The initial deletion can still interrupt a service.
Potential impact
If an encryption key is permanently lost, creating a new key may leave existing data unreadable.
Remediation
Purge protection is irreversible. Choose a recovery window of 7–90 days when creating the vault. The period is fixed after creation. Review deletion permissions and backups, then test recovery within that window.
Examples
Both examples use the same seven-day retention period. With protection off, someone with purge permission can permanently delete an item during those seven days.
Before
hcl
resource "azurerm_key_vault" "app_key_vault" {
name = "examplekeyvault"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
tenant_id = data.azurerm_client_config.current.tenant_id
sku_name = "standard"
soft_delete_retention_days = 7
purge_protection_enabled = false
}
After
hcl
resource "azurerm_key_vault" "app_key_vault" {
name = "examplekeyvault"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
tenant_id = data.azurerm_client_config.current.tenant_id
sku_name = "standard"
soft_delete_retention_days = 7
purge_protection_enabled = true
}