Cannot Delete Virtual Network Gateway in Azure
Asked Answered
A

3

6

I am attempting to delete a virtual network in Azure. When I use the web interface to delete it, it says

Virtual network 'MyVirtualNetwork' is in use and cannot be deleted. If you recently deleted resources, it might take some time to update the virtual network.

Of course, I didn't recently delete resources and there are no VMs using the network. I followed this StackOverflow post here which says that in order to delete a Virtual Network, you must first delete the Virtual Network Gateway.

So, as per the instructions "To delete a virtual network gateway" on MSDN here, I click through the Azure web interface like this:

Virtual Network > *MyVirtualNetwork* > Dashboard > Delete Gateway

And I get this:

Failed to delete the gateway for virtual network 'OneCoreWikiVnet'.

Azure offers no further explanation or other details.

How do I delete this virtual network gateway?

Ailis answered 21/4, 2014 at 20:30 Comment(1)
I
3

Yes. As you know it correctly that you have to delete all the subnets shown under settings section before you are able to delete the virtual network itself as shown in the snapshot below. As you can see that I've got two subnets namely GatewaySubnet and Subnet 1.

enter image description here

You can delete all the subnets except GatewaySubnet using delete option shown under ... menu at the end of every row.

If you try deleting the GatewaySubnet from the same ... option it gives you an error saying:

The gateway subnet cannot be deleted.

Now the question remains as to how to delete the GatewaySubnet. Here is the step by step process to accomplish the same:

  1. Go to Overview tab and click on the gateway icon shown with a green check mark in the right pane.

enter image description here

  1. On the gateway detail screen click the delete button in left pane:

enter image description here

  1. Click Yes on the warning message which says Are you sure you want to delete this gateway?

  2. This will result in deletion of the GatewaySubnet. You can observe now on the overview tab that icon of Gateway has turned grey and its brief description reads Click here to create a gateway.

enter image description here

  1. Now just click on the delete button to get rid of the virtual network in entirety.
Indissoluble answered 2/3, 2017 at 1:18 Comment(0)
J
2

The azure object hierarchy is as follows.

Virtual Network --> Virtual Network Gateway --> Connections

To delete, you should delete from bottom up (or right to left in this case). Essentially, to delete a VNET gateway you need to ensure that any connection on the gateway is removed first.

Jeweljeweler answered 25/5, 2016 at 14:10 Comment(0)
S
1

Have you tried to use the PowerShell cmdlet to do this?

Remove-AzureVNetGateway -VNetName

You can put -Verbose on there if you're still hitting an error and maybe get a better error response.

Sendal answered 21/4, 2014 at 21:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.