Unable to delete VNet due to serviceAssociationLinks/AppServiceLink

Kien_NDM 116 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.

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
35,998 questions
{count} votes

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

    @Kien_NDM , Apologies for the delay in response. This is a known issue, and the only way you will be able to get this deleted is to contact Azure Support. If you do not have a support plan, please Email me at with your subscription ID and a link to this post, and I will enable a one-time free support request for you to get the subnet deleted.

    Workaround:

    1. Create App Service Plan with the same name as the deleted one
    2. Create App Service with the same name as the deleted one
    3. Link App Service with the VNET subnet
    4. Disconnect VNet from App Service -> Networking -> VNet integration -> Disconnect
    5. Delete subnet

    Reason for this Error:
    The new VNET integration feature (Regional Vnet Integration) must set locks on subnets in the Network Resource Provider, we set these locks by putting a structure called a Service Association Link onto the Subnet, which is a privileged operation that only Microsoft.Web and some other internal Azure services have access to, this ends up being odd cases where these locks don't get cleaned up. The result is that the customer will have a subnet that cannot be deleted or used because a Service Association Link still exists on the subnet.
    Azure App Service and Azure Networking Product Group keep working on to fix the issue completely.

    ----------

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

    11 people found this answer helpful.

8 additional answers

Sort by: Most helpful
  1. Jose Wildner 10 Reputation points
    2023-03-25T02:59:05.11+00:00

    Hello Team

    I had the same issue

    but I coulnd't apply the workaround and the azure portal dont leave me open a case for this issue, just fowarding me to this post.

    2 people found this answer helpful.
    0 comments No comments

  2. Al Iacovella 0 Reputation points
    2023-05-19T16:22:24.31+00:00

    Just ran into this myself. What gives, this was reported in October 2020 and it is still happening.


  3. Samuel Nihipali 0 Reputation points
    2023-07-26T22:21:48.31+00:00

    I'm getting this error as well. I had an Web app + Database and didn't realize that I had to disconnect the subnet from the vnet before deleting the resource group. Not I can't delete the subnet or vnet. I've tried recreating but it either fails because the resource already exists or unable to assign the subnet due to it being assigned already. Any chance of getting a one-time support ticket?

    0 comments No comments

  4. Samuel Nihipali 0 Reputation points
    2023-07-26T22:22:28.61+00:00

    I'm getting this error as well. I had an Web app + Database and didn't realize that I had to disconnect the subnet from the vnet before deleting the resource group. Not I can't delete the subnet or vnet. I've tried recreating but it either fails because the resource already exists or unable to assign the subnet due to it being assigned already. Any chance of getting a one-time support ticket?

    0 comments No comments