Cannot remove Azure Subnet. stuck with VNet Integration / Delegation

Alex 1 Reputation point
2022-08-25T14:35:17.067+00:00

We are trying to remove a subnet which we need to recreate (others subnet range)..
But whatever I try, this keeps on failing with the following message:

“Subnet wgkovl-sn-tst030pictureapi is in use by /subscriptions/axxx-xxxx-xxxx-xxx-xxxxxx/resourceGroups/wgkovl-rg-network/providers/Microsoft.Network/virtualNetworks/wgkovl-vn/subnets/wgkovl-sn-tst030pictureapi/serviceAssociationLinks/AppServiceLink and cannot be deleted. In order to delete the subnet, delete all the resources within the subnet. See aka.ms/deletesubnet.”

As far as I reviewed, everything related to this subnet, has been deleted already.

Any help/idea/… is welcome

Initially, this subnet has been linked to an App Service Plan with VNet Integration.. but it wasn't deassociated.
We have no more knowledge of the original components to which it was linked. Those have been removed already.

(edited: PII for privacy)

Azure Virtual Network
Azure Virtual Network
An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.
2,312 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,408 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Alex 1 Reputation point
    2022-08-26T06:29:35.957+00:00

    The solution :
    If you no longer remember the name of the App Service Plan, you can find it using Powershell...

    $vnetObject=Get-AzVirtualNetwork -Name [virtual Network Name] -ResourceGroupName [Resource Group Name]
    $snObject=get-AzVirtualNetworkSubnetConfig -Name [Name of the Subnet you want to delete] -VirtualNetwork $vnetObject

    In the result, you will find the name of the ASP using: $sn.ServiceAssociationLinks[0].Link

    Recreate that ASP, create a new functionApp with VNet Integration, using your Subnet..
    open the newly created ASP, go to Network - VNet Integration and click DISCONNECT.

    Give this a few minutes after which you should be able to delete the Subnet again.