An Azure service that provides a general-purpose, serverless container platform.
For a Container Apps managed environment that is stuck in ScheduledForDelete and blocking subnet reuse, perform the following cleanup steps.
- 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
- Ensure the latest Container Apps extension is installed and updated, especially if seeing odd or missing-parameter errors:
- If using PowerShell, ensure the
Az.Appmodule is installed/updated:Install-Module -Name Az.App Update-Module -Name Az.App
- Manually delete the VNet used by the Container Apps environment
If the environment shows
provisioningState: ScheduledForDeleteand 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>
- 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.
- 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:
- Troubleshoot a container app
- ManagedEnvironmentResource.Delete(WaitUntil, CancellationToken) Method
- ManagedEnvironmentResource.DeleteAsync(WaitUntil, CancellationToken) Method
- ContainerAppManagedEnvironmentResource.Delete Method
- Troubleshoot failure to delete or modify a virtual network or subnet in Azure
- Troubleshoot subnet deletion and modification failures in Azure Virtual Network
- Subnet deletion blocked by orphaned App Service serviceAssociationLink - Microsoft Q&A
- Azure Container Apps environments