The Features Block

The Azure Provider allows the behaviour of certain resources to be configured using the features block.

This allows different users to select the behaviour they require, for example some users may wish for the OS Disks for a Virtual Machine to be removed automatically when the Virtual Machine is destroyed - whereas other users may wish for these OS Disks to be detached but not deleted.

Example Usage

If you wish to use the default behaviours of the Azure Provider, then you only need to define an empty features block as below:

provider "azurerm" {
  features {}
}

Each of the blocks defined below can be optionally specified to configure the behaviour as needed - this example shows all the possible behaviours which can be configured:

provider "azurerm" {
  features {
    api_management {
      purge_soft_delete_on_destroy = true
      recover_soft_deleted         = true
    }

    app_configuration {
      purge_soft_delete_on_destroy = true
      recover_soft_deleted         = true
    }

    application_insights {
      disable_generated_rule = false
    }

    cognitive_account {
      purge_soft_delete_on_destroy = true
    }

    key_vault {
      purge_soft_delete_on_destroy    = true
      recover_soft_deleted_key_vaults = true
    }

    log_analytics_workspace {
      permanently_delete_on_destroy = true
    }

    machine_learning {
      purge_soft_deleted_workspace_on_destroy = true
    }

    managed_disk {
      expand_without_downtime = true
    }

    postgresql_flexible_server {
      restart_server_on_configuration_value_change = true
    }

    recovery_service {
      retain_data_and_stop_protection_on_back_vm_destroy = true
      purge_protected_items_from_vault_on_destroy        = true
    }

    resource_group {
      prevent_deletion_if_contains_resources = true
    }

    recovery_services_vault {
      recover_soft_deleted_backup_protected_vm = true
    }

    subscription {
      prevent_cancellation_on_destroy = false
    }

    template_deployment {
      delete_nested_items_during_deletion = true
    }

    virtual_machine {
      delete_os_disk_on_deletion     = true
      graceful_shutdown              = false
      skip_shutdown_and_force_delete = false
    }

    virtual_machine_scale_set {
      force_delete                  = false
      roll_instances_when_required  = true
      scale_to_zero_before_deletion = true
    }
  }
}

Arguments Reference

The features block supports the following:


The api_management block supports the following:


The app_configuration block supports the following:


The application_insights block supports the following:


The cognitive_account block supports the following:


The key_vault block supports the following:


The log_analytics_workspace block supports the following:


The machine_learning block supports the following:


The managed_disk block supports the following:


The postgresql_flexible_server block supports the following:


The recovery_service block supports the following:


The resource_group block supports the following:


The recovery_services_vault block supports the following:


The subscription block supports the following:


The template_deployment block supports the following:


The virtual_machine block supports the following:


The virtual_machine_scale_set block supports the following: