An Azure service that provides a general-purpose, serverless container platform.
I do not want to delete the vnet. The vnet must be used by another caenv.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Container Apps Managed Environment stuck in ScheduledForDelete for multiple days. Subnet is blocked and cannot be reused. Requesting backend force deletion / cleanup.
An Azure service that provides a general-purpose, serverless container platform.
I do not want to delete the vnet. The vnet must be used by another caenv.
I do not want to delete the vnet.
AI answer
For a Container Apps managed environment that is stuck in ScheduledForDelete and blocking subnet reuse, perform the following cleanup steps.
az containerapp:
az extension add --name containerapp --upgrade
az extension add --name containerapp --upgrade --allow-preview true
Az.App module is installed/updated:
Install-Module -Name Az.App
Update-Module -Name Az.App
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>
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.
the environment still remains stuck in ScheduledForDelete and the subnet remains blocked, open a support case with Microsoft. Provide:
infrastructureSubnetIdThis allows backend engineering to force-clean the environment and unblock the subnet.
References: