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.


4 answers

Sort by: Oldest
  1. 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?

  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. 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

  4. Rakesh Mishra 11,290 Reputation points Microsoft External Staff Moderator
    2026-06-15T14:56:19.55+00:00

    Hello Kelby,

    Thank you for reaching out to the Microsoft Q&A platform.

    I understand you are experiencing an issue where your Azure Container Apps Managed Environment is stuck in the ScheduledForDelete state for multiple days, leaving your subnet blocked by lingering network associations. I also noted your comment that you do not want to delete the Virtual Network because it must be used by another Container Apps Environment.

    This behavior occurs because the Azure Container Apps resource provider encountered a timeout or control-plane failure during the background de-provisioning process. As a result, the backend resources are orphaned, and the Service Association Link (SAL) remains on your subnet.

    According to the official Azure Virtual Network troubleshooting documentation:

    "You can't delete or modify a subnet if it has resources connected to it. These resources include... service association links... If a subnet is delegated to a service, you must first remove the delegation."

    However, because Container Apps is a managed service, the Service Association Links (Microsoft.App/environments) are locked by the Resource Provider. Attempting to manually delete the SAL or remove the delegation via CLI/Portal will result in an authorization or resource lock error.

    To confirm above, run the following Azure CLI command to query the service association links on your subnet:

    az network vnet subnet show \
      --resource-group <Your-Resource-Group> \
      --vnet-name <Your-VNet-Name> \
      --name <Your-Subnet-Name> \
      --query "serviceAssociationLinks[].{Name:name, Type:linkedResourceType, ProvisioningState:provisioningState}" \
      --output table
    

    Interpreting the Results: If the output displays a record with the Type Microsoft.App/environments, this confirms that the Container Apps resource provider still holds an active lock on your subnet, despite your environment being stuck in the ScheduledForDelete state.

    How to resolve this:

    Since the environment is permanently stuck in ScheduledForDelete, this requires aforce-cleanup by backend Team via Support request. We cannot manually force the deletion from the user side once the resource provider lock is in this hung state.

    In Private message, please share the following details so the internal engineering team can forcefully purge the orphaned locks:

    • Subscription ID
    • Resource Group Name
    • Stuck Managed Environment Name
    • Virtual Network and Subnet Name
    • Approximate time the deletion was initially requested
    • Subnet URI

    Workaround to unblock your deployment: Since you need to use the existing VNet for a new Container Apps Environment, you do not need to wait for support to deploy your new workloads. You can create a new subnet within the same VNet, delegate it to Microsoft.App/environments, and deploy your new Container App Environment there while Microsoft Support cleans up the blocked subnet.

    Hope this helps!

    Was this answer helpful?

    0 comments No comments

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.