Troubleshooting: Failed to delete a virtual network in Azure
You might receive errors when you try to delete a virtual network in Microsoft Azure. This article provides troubleshooting steps to help you resolve this problem.
If your Azure issue is not addressed in this article, visit the Azure forums on Microsoft Q & A and Stack Overflow. You can post your issue in these forums, or post to @AzureSupport on Twitter. You also can submit an Azure support request. To submit a support request, on the Azure support page, select Get support.
Troubleshooting guidance
- Check whether a virtual network gateway is running in the virtual network.
- Check whether an application gateway is running in the virtual network.
- Check whether Azure container instances still exist in the virtual network.
- Check whether Microsoft Entra Domain Service is enabled in the virtual network.
- Check whether the virtual network is connected to other resource.
- Check whether a virtual machine is still running in the virtual network.
- Check whether the virtual network is stuck in migration.
- Check whether the virtual network was used by a web app for VNet integration.
Troubleshooting steps
Check whether a virtual network gateway is running in the virtual network
To remove the virtual network, you must first remove the virtual network gateway.
For classic virtual networks, go to the Overview page of the classic virtual network in the Azure portal. In the VPN connections section, if the gateway is running in the virtual network, you will see the IP address of the gateway.
For virtual networks, go to the Overview page of the virtual network. Check Connected devices for the virtual network gateway.
Before you can remove the gateway, first remove any Connection objects in the gateway.
Check whether an application gateway is running in the virtual network
Go to the Overview page of the virtual network. Check the Connected devices for the application gateway.
If there is an application gateway, you must remove it before you can delete the virtual network.
Check whether Azure container instances still exist in the virtual network
In the Azure portal, go to the resource group's Overview page.
In the header for the list of the resource group's resources, select Show hidden types. The network profile type is hidden in the Azure portal by default.
Select the network profile related to the container groups.
Select Delete.
Delete the subnet or virtual network again.
If these steps don't resolve the issue, use these Azure CLI commands to clean up resources.
Check whether Microsoft Entra Domain Service is enabled in the virtual network
If the Active Directory Domain Service is enabled and connected to the virtual network, you cannot delete this virtual network.
To disable the service, see Disable Microsoft Entra Domain Services using the Azure portal.
Check whether the virtual network is connected to other resource
Check for Circuit Links, connections, and virtual network peerings. Any of these can cause a virtual network deletion to fail.
The recommended deletion order is as follows:
- Gateway connections
- Gateways
- IPs
- Virtual network peerings
- App Service Environment (ASE)
Check whether a virtual machine is still running in the virtual network
Make sure that no virtual machine is in the virtual network.
Check whether the virtual network is stuck in migration
If the virtual network is stuck in a migration state, it cannot be deleted. Run the following command to abort the migration, and then delete the virtual network.
Move-AzureVirtualNetwork -VirtualNetworkName "Name" -Abort
Check whether the virtual network was used by a web app for VNet integration
If the virtual network was integrated with a web app in the past, then the web app was deleted without disconnecting the VNet integration, see Deleting the App Service plan or web app before disconnecting the VNet integration.