Unable to delete VNet due to serviceAssociationLinks/AppServiceLink

Kien_NDM 136 Reputation points
2020-10-27T01:28:29.92+00:00

Hi,

I have deployed an Azure system including virtual networks and app services. Then, when doing virtual network deletion, I had some problems. I got the message and the subnet uses the above vnet. Then I delete the subnet and get the message that there are app services using the above subnet. In fact, there are no app services at all. When using the command below:

az network vnet subnet list --resource-group [...] --vnet-name [...]

As a result, I discovered that 1 [Microsoft.Network/virtualNetworks/subnets/serviceAssociationLinks] cannot be deleted.

Remove-AzureRmVirtualNetwork : Subnet snet-bo is in use by /subscriptions/[..id...]/resource
Groups/Disabled/providers/Microsoft.Network/virtualNetworks/vnet-drug/subnets/snet-bo/serviceAssociationLinks/AppServic
eLink and cannot be deleted. In order to delete the subnet, delete all the resources within the subnet. See
aka.ms/deletesubnet.
StatusCode: 400
ReasonPhrase: Bad Request
OperationID : 'bbc8987b-ffd1-420e-80c7-5913ef43b069'
At line:1 char:1

  • Remove-AzureRmVirtualNetwork -Name vnet-drug -ResourceGroupName disab ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : CloseError: (:) [Remove-AzureRmVirtualNetwork], NetworkCloudException
  • FullyQualifiedErrorId : Microsoft.Azure.Commands.Network.RemoveAzureVirtualNetworkCommand

Please support, thank you.

Community Center | Not monitored
{count} votes

Accepted answer
  1. suvasara-MSFT 10,076 Reputation points Moderator
    2020-10-28T10:31:48.677+00:00

    The steps below outline a workaround you can try to resolve it.

    Workaround Steps:

    1. Create an App Service Plan with the same name as the deleted one.
    2. Create an App Service with the same name as the deleted one.
    3. Link the App Service to the VNet subnet.
    4. Disconnect the VNet from the App Service:
    5. Go to Networking > VNet Integration > Disconnect.
    6. Delete the subnet.

    Reason for the Issue:

    This issue occurs because the new VNet Integration feature (Regional VNet Integration) adds locks to subnets using a structure called a Service Association Link (SAL). These locks, managed by Azure's internal services like Microsoft.Web, occasionally fail to clean up properly. As a result, the subnet remains locked, preventing deletion or reuse.

    Next Steps:

    If the workaround does not resolve the issue, you will need to contact Azure Support for assistance.

    If you do not have a support plan, please email me with your Subscription ID and a link to this post. I will help enable a one-time free support request so that you can proceed with deleting the subnet.

    ----------

    Please do not forget to "Accept the answer" wherever the information provided helps you to help others in the community.

    15 people found this answer helpful.

5 additional answers

Sort by: Most helpful
  1. Craig H 5 Reputation points
    2025-05-12T08:18:33.98+00:00

    Also encountering the same issue despite attempting all documented workarounds, and also don't have a support subscription. It's madness to expect us to create a support subscription plan just to delete a resource which can't be manually deleted on account of this Azure bug which has lingered for several years. I would appreciate a member of the Support Team DM'ing me directly please.

    1 person found this answer helpful.
    0 comments No comments

  2. Marcel Dutt 0 Reputation points
    2023-08-08T12:22:57.3266667+00:00

    If you experience this behavior with Function Apps and possibly Terraform: if you have deployment slots and delete the slot before the connection to the VNET has been severed, it will be impossible to disconnect. This may happen with Terraform if you have set the app setting "WEBSITE_VNET_ROUTE_ALL" = 1. Workaround: Recreate the slot with the same name. Set "WEBSITE_VNET_ROUTE_ALL" = 0 and then disconnect from the VNET in the Network blade of the function app in the portal. Then proceed with whatever you wanted to do (in portal or via Terraform).

    0 comments No comments

  3. Giovani Decusati 5 Reputation points
    2023-12-27T06:00:08.9033333+00:00

    Hi team,

    I'm having the same problem. The solution above doesn't works as per as I'm not able to select the subnet for enabling VNET integration.

    Remove-AzVirtualNetwork -ResourceGroupName MyRG-Name xxxx


    Remove-AzVirtualNetwork: Subnet xxx-web is in use by /subscriptions/xxxx-c0e3-4b89-be00-0524b96b7b0f/resourceGroups/xxxxx/providers/Microsoft.Network/virtualNetworksxxxx/subnets/xxx-web/serviceAssociationLinks/AppServiceLink and cannot be deleted. In order to delete the subnet, delete all the resources within the subnet. See aka.ms/deletesubnet.

    StatusCode: 400

    ReasonPhrase: Bad Request

    ErrorCode: InUseSubnetCannotBeDeleted

    ErrorMessage: Subnet xxxxx-web is in use by /subscriptions/xxxxxx-c0e3-4b89-be00-0524b96b7b0f/resourceGroups/xxxxx/providers/Microsoft.Network/virtualNetworks/xxxx/subnets/xxxx-web/serviceAssociationLinks/AppServiceLink and cannot be deleted. In order to delete the subnet, delete all the resources within the subnet. See aka.ms/deletesubnet.

    OperationID : 9223cb66-265d-4e7e-885e-33de6d52d5e2

    0 comments No comments

  4. Michel Hernandez 0 Reputation points
    2024-01-05T11:57:04.4333333+00:00

    Hello Team,

    For those that the workaround didn't work make sure you are using the 'Gateway-based integration' to link the subnet with the App Service again. This will allow you to set up the Virtual Network Integration again. Once is done, you can 'Disconnect' and perform the delete operation.

    Hope this helps.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.