Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Container App Environment deletion takes over 20 minutes – Is this normal, and how can it be optimized?

I'm experiencing unusually long delays when managing an Azure Container App Environment (ACA Environment), both when deleting it through Terraform and the Azure Portal. Specifically, deleting the ACA Environment consistently takes more than 20 minutes. This seems strange because the associated resources (such as virtual networks and subnets) are relatively simple.

Here’s a simplified version of my Terraform configuration:

resource "azurerm_virtual_network" "virtual_network" {
  name                = "vnet-${var.environment}-${var.location}-001"
  address_space       = ["10.0.0.0/16"]
  location            = var.location
  resource_group_name = azurerm_resource_group.resource_group.name

  tags = local.global_tags
}

resource "azurerm_subnet" "apis_subnet" { 
  name                 = "snet-apis-${var.location}-001"
  resource_group_name  = azurerm_resource_group.resource_group.name
  virtual_network_name = azurerm_virtual_network.virtual_network.name
  address_prefixes     = ["10.0.1.0/24"]

  delegation {
    name = "delegation"
    service_delegation {
      name    = "Microsoft.App/environments"
      actions = ["Microsoft.Network/virtualNetworks/subnets/join/action"]
    }
  }

  lifecycle {
    prevent_destroy = false
    ignore_changes  = [address_prefixes]
  }
}

resource "azurerm_container_app_environment" "container_app_environment" { 
  name                = "cae-something-${var.location}-${var.environment}-001"
  location            = var.location
  resource_group_name = azurerm_resource_group.resource_group.name

  infrastructure_subnet_id = azurerm_subnet.apis_subnet.id

  workload_profile {
    name                  = "Consumption"
    workload_profile_type = "Consumption"
  }
}

What I've Observed

  1. Deleting the ACA Environment through Terraform or the Azure Portal takes over 20 minutes.
  2. Resources such as virtual networks and subnets are typically faster to manage, so this delay seems unexpected.

What I Want to Know

  1. Is it normal for Azure Container App Environments to take this long to delete?
  2. Are there any known best practices or optimizations to reduce this time?
  3. Could this delay be related to dependencies or configurations (e.g., the workload profile or subnet delegation)?

If you’ve run into something similar or have ideas on what might be causing this, I’d really appreciate your help!

like image 833
Tiago Ferreira Avatar asked Nov 22 '25 22:11

Tiago Ferreira


1 Answers

Azure Container App Environment deletion takes over 20 minutes – Is this normal, and how can it be optimized?

The Azure Container App Environment takes a longer time for resource creation and deletion, typically when the associated resources (like the VNet and subnet) are simple configurations. Deletion times can vary depending on several factors, such as the presence of active workloads, network configurations, or Azure platform performance at the time.

Terraform also gives a default of 30 minutes to delete an Azure Container App. Follow the link for more details

enter image description here

Even when I tried to delete the ACA using Terraform, it took 21 minutes to delete.

enter image description here

To better understand what Terraform is doing during the deletion process, enable Terraform debugging

$env:TF_LOG="DEBUG"
terraform destroy
like image 155
Venkateswarlu V Avatar answered Nov 24 '25 10:11

Venkateswarlu V



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!