Cannot remove serviceAssociationLink from subnet due to orphaned Microsoft.App/environments link

木本 瑞希 85 Reputation points
2025-06-17T11:07:36.3133333+00:00

We are unable to remove a serviceAssociationLink from the following subnet:

/subscriptions/34872a55-0fad-4390-a95c-711e453c160f/resourceGroups/rg-devplaton-agent2/providers/Microsoft.Network/virtualNetworks/agents-vnet/subnets/agent-subnet

This link references a Microsoft.App/environments resource that no longer exists. The linked managed environment has already been deleted, but the subnet is still showing a serviceAssociationLink named legionservicelink.

The link has the property "allowDelete": false, and prevents us from updating, deleting, or reusing the subnet. All attempts to delete or remove the link via CLI have failed.

We set up this environment using the following official sample script provided by Azure AI Foundry:

https://github.com/azure-ai-foundry/foundry-samples/tree/main/samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup

After deleting the environment, the serviceAssociationLink was not automatically cleaned up, resulting in this orphaned state.

We kindly request Microsoft support to manually remove or clean up the orphaned serviceAssociationLink from the subnet so we can reuse or delegate it properly.

Thank you.

Azure App Service
Azure App Service

Azure App Service is a service used to create and deploy scalable, mission-critical web apps.


Answer accepted by question author

Amira Bedhiafi 43,046 Reputation points MVP Volunteer Moderator
2025-06-17T18:50:29.6933333+00:00

Hello !

Thank you for posting on Microsoft Learn !

What I have see so far, this is a common issue in Azure where orphaned serviceAssociationLinkremain on a subnet after a Microsoft.App/environments (Azure Container Apps Environment) is deleted, especially when set up using scripts like the one from Azure AI Foundry. These links can block subnet reuse and can't be deleted due to "allowDelete": false.

The serviceAssociationLink was created by the managed environment, but the automatic cleanup failed during deletion. Azure has no current public method (via CLI/Portal) to force deletion such orphaned links if the parent resource no longer exists.

The only way to resolve the issue currently is to open a support ticket since the link has allowDelete: false, somanual removal by Microsoft backend is required.

Meanwhile as a workaround, while you get the support, ceate a new subnet in the same VNet and update your deployments to use the new subnet as this avoids the blocked subnet but is not ideal if address space is constrained.

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Amy Harris (SHE/HER) 0 Reputation points Microsoft Employee
    2025-08-18T18:27:39.5533333+00:00

    There is a deleteCapHost.sh file in the foundry-samples repo. You can use this to clear the capability host and delete the subnet. You'll need to find the name of the AI Foundry resource. If it was already deleted, you should be able to find the name in the Deployments history of the resource group. It will look like "aiservices<some random characters>". Then when it asks for the capability host name, the default value in the template is "caphostproj".

    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.