Unable to delete vnet

James Gibson 20 Reputation points
2023-08-21T08:49:13.81+00:00

Unable to delete VNet and/or resource group because of AppServiceLink , but the app service is deleted.

Looks like https://learn.microsoft.com/en-us/answers/questions/656042/error-deleting-subnet-serviceassociationlinks-apps but I can't do the workaround because I don't know what the app service plan and app service names were.

How can I delete this vnet?

 Resource
	/subscriptions/*****/resourceGroups/vnet-test2/providers/Microsoft.Network/virtualNetworks/jagvnettest2-vnet/subnets/WebAndApiOutbound
Operation name 
	Delete Virtual Network Subnet
Time stamp
	Mon Aug 21 2023 09:03:23 GMT+0100 (British Summer Time)
Event initiated by 
	***@****
Error code
	InUseSubnetCannotBeDeleted
Message
	Subnet WebAndApiOutbound is in use by /subscriptions/*****/resourceGroups/vnet-test2/providers/Microsoft.Network/virtualNetworks/jagvnettest2-vnet/subnets/WebAndApiOutbound/serviceAssociationLinks/AppServiceLink and cannot be deleted. In order to delete the subnet, delete all the resources within the subnet. See aka.ms/deletesubnet.
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.
{count} votes

Answer accepted by question author
  1. TP 145.8K Reputation points Volunteer Moderator
    2023-08-21T16:10:22.0433333+00:00

    Hi James,

    You can find out the app service plan name and resource group name that it was/is in by reading the Service Association Link on your subnet:

    https://learn.microsoft.com/en-us/rest/api/virtualnetwork/service-association-links/list?tabs=HTTP&tryIt=true&source=docs#code-try-0

    Before running the command using above link, you need to enter the resource group name for your virtual network, your subnet name, and the virtual network name in the boxes. After you Run the command, look in the output for "link": "/subscriptions/<subscription ID>/resourceGroups/<resourceGroupName of App Service>/providers/Microsoft.Web/serverfarms/<App Service Plan Name>" which should have the resource group name and app service plan name for the deleted app.

    Once you have the above information, hopefully that will be enough for you to follow steps in below article:

    Deleting the App Service plan or app before disconnecting the network integration

    https://learn.microsoft.com/en-us/azure/app-service/overview-vnet-integration#deleting-the-app-service-plan-or-app-before-disconnecting-the-network-integration

    If you are unable to remove it using above instructions then you will need to create New support request and a support engineer will take care of it.

    Please click Accept Answer if the above was useful.

    Thanks.

    -TP

    1 person found this answer helpful.

0 additional answers

Sort by: Most 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.