Container Apps Managed Environment stuck in ScheduledForDelete for multiple days

Kelby Tansley 0 Reputation points
2026-06-15T13:43:09.6966667+00:00

Container Apps Managed Environment stuck in ScheduledForDelete for multiple days. Subnet is blocked and cannot be reused. Requesting backend force deletion / cleanup.

Azure Container Apps
Azure Container Apps

An Azure service that provides a general-purpose, serverless container platform.


3 answers

Sort by: Most helpful
  1. Kelby Tansley 0 Reputation points
    2026-06-15T14:34:16.0633333+00:00

    I do not want to delete the vnet. The vnet must be used by another caenv.

    Was this answer helpful?

    0 comments No comments

  2. Kelby Tansley 0 Reputation points
    2026-06-15T14:33:23.0833333+00:00

    I do not want to delete the vnet.

    Was this answer helpful?

    0 comments No comments

  3. AI answer

    2026-06-15T13:43:28.0466667+00:00

    For a Container Apps managed environment that is stuck in ScheduledForDelete and blocking subnet reuse, perform the following cleanup steps.

    1. Verify and update Container Apps tooling
    • If using Azure CLI and az containerapp:
      • Ensure the latest Container Apps extension is installed and updated, especially if seeing odd or missing-parameter errors:
            az extension add --name containerapp --upgrade
        
      • If using preview features, enable them:
            az extension add --name containerapp --upgrade --allow-preview true
        
    • If using PowerShell, ensure the Az.App module is installed/updated:
        Install-Module -Name Az.App
        Update-Module -Name Az.App
      
    1. Manually delete the VNet used by the Container Apps environment If the environment shows provisioningState: ScheduledForDelete and does not complete deletion, manually delete the associated VNet and then retry the environment deletion.

    a. Identify the VNet and subnet used by the environment

    az containerapp env show \
      --resource-group <RESOURCE_GROUP> \
      --name <ENVIRONMENT>
    

    In the output, locate infrastructureSubnetId and note the VNet and subnet.

    b. Check for blocking configurations on the subnet (delegations, SALs, endpoints, etc.) Use diagnostic commands on the subnet to see what is still attached and blocking deletion or reuse:

    az network vnet subnet show \
      --resource-group <RESOURCE_GROUP> \
      --vnet-name <VNET_NAME> \
      --name <SUBNET_NAME> \
      --query "delegations[].{name:name, service:serviceName}" \
      --output table
    

    Also inspect serviceAssociationLinks, ipConfigurations, privateEndpoints, and other fields as described in the diagnostic guidance. Any non-empty field indicates resources that must be removed before the subnet or VNet can be deleted or reused.

    If the subnet is delegated to a service, delete all resources using that delegation, then remove the delegation:

    az network vnet subnet update \
      --resource-group <RESOURCE_GROUP> \
      --vnet-name <VNET_NAME> \
      --name <SUBNET_NAME> \
      --remove delegations
    

    If a service association link (SAL) is orphaned (for example, from App Service or another service that no longer exists), purge the orphaned SAL using the recommended purge command for that service. If purge is not sufficient, re-create the service integration and then disconnect it, as described in the referenced Q&A, so the SAL is removed and the subnet can be freed.

    c. Delete the VNet Once all blocking resources (delegations, SALs, NICs, private endpoints, etc.) are removed:

    az network vnet delete \
      --resource-group <RESOURCE_GROUP> \
      --name <VNET_NAME>
    
    1. Retry deleting the Container Apps managed environment After the VNet is removed, retry deleting the environment:
    az containerapp env delete \
      --resource-group <RESOURCE_GROUP> \
      --name <ENVIRONMENT> \
      --yes
    

    If using the .NET Azure Resource Manager SDK instead of CLI, use the Delete or DeleteAsync methods on the managed environment resource, ensuring there are no container apps in the environment:

    // Synchronous
    ArmOperation operation = managedEnvironment.Delete(WaitUntil.Completed, cancellationToken);
    
    // Asynchronous
    ArmOperation asyncOperation = await managedEnvironment.DeleteAsync(WaitUntil.Completed, cancellationToken);
    

    These operations call the ManagedEnvironments_Delete API, which succeeds only when no container apps remain in the environment.

    1. When to escalate to Microsoft Support If, after:
    • Removing all container apps from the environment,
    • Cleaning up all subnet/VNet dependencies (delegations, SALs, NICs, private endpoints), and
    • Retrying environment deletion via CLI or SDK,

    the environment still remains stuck in ScheduledForDelete and the subnet remains blocked, open a support case with Microsoft. Provide:

    • Environment name and resource group
    • Subscription ID
    • infrastructureSubnetId
    • Timeline and commands already attempted

    This allows backend engineering to force-clean the environment and unblock the subnet.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.