title | description | services | documentationcenter | author | manager | editor | tags | ms.service | ms.topic | ms.tgt_pltfrm | ms.workload | ms.date | ms.author | ms.custom |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Cannot delete a virtual network in Azure | Microsoft Docs |
Learn how to troubleshoot the issue in which you cannot delete a virtual network in Azure. |
virtual-network |
na |
chadmath |
dcscontentpm |
azure-resource-manager |
virtual-network |
troubleshooting |
na |
infrastructure-services |
10/31/2018 |
genli |
fasttrack-edit |
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.
[!INCLUDE support-disclaimer]
- 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 Azure Active Directory 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.
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.
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.
-
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.
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 Azure Active Directory Domain Services using the Azure portal.
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)
Make sure that no virtual machine is in the virtual network.
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
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.