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 MSDN 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

  1. Check whether a virtual network gateway is running in the virtual network.
  2. Check whether an application gateway is running in the virtual network.
  3. Check whether Azure Active Directory Domain Service is enabled in the virtual network.
  4. Check whether the virtual network is connected to other resource.
  5. Check whether a virtual machine is still running in the virtual network.
  6. Check whether the virtual network is stuck in migration.

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.

Check whether gateway is running

For virtual networks, go to the Overview page of the virtual network. Check Connected devices for the virtual network gateway.

Check the connected device

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.

Check the connected device

If there is an application gateway, you must remove it before you can delete the virtual network.

Check whether Azure Active Directory 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.

Check the connected device

To disable the service, see Disable Azure Active Directory 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:

  1. Gateway connections
  2. Gateways
  3. IPs
  4. Virtual network peerings
  5. 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

Next steps