Unable to delete Container App Environment which status shows as "Scheduled for Delete"

Karthic Ganesan 20 Reputation points
2025-11-26T22:56:44.54+00:00
  • 1st iteration of Terraform Apply: Deployed Container App environment with private endpoint along with 1 container app via 1 and container app failed to instantiate due image pull failure.
  • 2nd iteration of Terraform Apply: Container App Environment went into the status "Scheduled for Delete" because, it tried to delete the empty container app environment. During this iteration, its managed resource group and private endpoint got successfully deleted except the Container App Environment.
  • Tried deleting this container app environment manually using Azure Portal UI and Az CLI, but no success. Even if I tried to delete the entire resource group, resource group vanishes for 30 mins only and it comes back after (weir
  • Tried to delete its container app environment subnet with delegation Microsoft.App/environments and that is failing because it has associated with serviceAssociationLinks/legionservicelink which has "allowDelete: false".

So only way to delete these orphaned resources through backend. Unfortunately we have only Basic support plan, hence I can's raise support request. Could someone from Microsoft Support team help here to delete these container app environment and service link at backend? I will send the subscription and resource details in private.

Azure Container Apps
Azure Container Apps
An Azure service that provides a general-purpose, serverless container platform.
{count} votes

Answer accepted by question author
  1. Siddhesh Desai 735 Reputation points Microsoft External Staff Moderator
    2025-11-27T13:11:57.3933333+00:00

    Hi Karthic Ganesan,

    Did you try deleting the v-net, subnet and container app using terraform destroy command?

    Also, can you use below cli command:

    You can first delete the Service Association links on the V-Net by using this command:

    Azure CLI

    az rest --method delete --uri https://management.azure.com/subscriptions/<subscription id>/resourceGroups/<resource group>/providers/Microsoft.Network/virtualNetworks/<vnet name>/subnets/<subnet name>/providers/Microsoft.ContainerInstance/serviceAssociationLinks/default?api-version=2018-10-01
    

    And then remove subnet-delegation by using the command below:

    Azure CLI

    az network vnet subnet update --resource-group <resource group name> --name <subnet name> --vnet-name <vnet name> --remove delegations
    

    Ref: https://sathyasays.com/2021/06/05/delete-azure-vnet-subnet-delegation/

    After the associations and delegations are removed, Retry the deletion of the V-NET and container app.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Karthic Ganesan 20 Reputation points
    2025-11-26T23:05:36.7366667+00:00

    Your Bot suggested me to delete the Container App Environment and its Virtual Network via Az CLI commands. As I stated in Question, Az CLI based Container App Environment is failing and I can't delete the Virtual Network because it has been shared by other services via its other subnets.


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.