Skip to content

Files

Latest commit

f030772 · Jan 11, 2022

History

History
114 lines (73 loc) · 6.11 KB

virtual-network-troubleshoot-cannot-delete-vnet.md

File metadata and controls

114 lines (73 loc) · 6.11 KB
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

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.

[!INCLUDE support-disclaimer]

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 container instances still exist in the virtual network.
  4. Check whether Azure Active Directory Domain Service is enabled in the virtual network.
  5. Check whether the virtual network is connected to other resource.
  6. Check whether a virtual machine is still running in the virtual network.
  7. Check whether the virtual network is stuck in migration.
  8. 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.

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.

Screenshot of the list of Connected devices for a virtual network in Azure portal. The Virtual network gateway is highlighted in the list.

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.

Screenshot of the list of Connected devices for a virtual network in Azure portal. The Application gateway is highlighted in the list.

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

  1. In the Azure portal, go to the resource group's Overview page.

  2. 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.

  3. Select the network profile related to the container groups.

  4. Select Delete.

    Screenshot of the list of hidden network profiles.

  5. 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 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.

Screenshot of the Azure AD Domain Services screen in Azure portal. The Available in Virtual Network/Subnet field is highlighted.

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

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.

Next steps