Wednesday, August 24, 2016

Solving the "Virtual network myvnet is in use and cannot be deleted" issue when deleting a Windows Azure Virtual Network

While I like Azure, instructions for doing certain things are obfuscated or simply neglected.  Just purged my test network earlier today...

http://fabriccontroller.net/solving-the-virtual-network-myvnet-is-in-use-and-cannot-be-deleted-error-when-deleting-a-windows-azure-virtual-network/

May 3, 2013· LOCAL NETWORKSVIRTUAL NETWORKS

Solving the "Virtual network myvnet is in use and cannot be deleted" issue when deleting a Windows Azure Virtual Network

The last few days I've been testing out many different things with Virtual Networks (especially Site-to-Site VPN). Today I tried cleaning up all the mess I made but I had a few Virtual Networks which I couldn't delete.
Every time I tried to delete a Virtual Network I got this error message: 
Virtual network 'ContosoCloud' is in use and cannot be deleted. If you recently deleted resources, it might take some time to update the virtual network.
But my Virtual Network wasn't in use because I made changes to it, it was in use because I didn't remove the resources linking to this Virtual Network. This is what you'll need to do to get rid of a Virtual Network and a Local Network (exactly in this order):
  1. The first step is to delete the gateway in your Virtual Network. This can take a few minutes, so you will need to wait for it to complete before you can continue: 
  2. Once you've deleted the Gateway you will need to delete the next link to this Virtual Network. You can find them them under resources in the dashboard of your Virtual Network. 
    Don't worry about deleting the Virtual Machine. By deleting them, you're deleting nothing more than an XML file which describes where to find the data disk, the size of the VM, which ports to open, … So its very easy to re-create the Virtual Machine (with the same data) through the portal or by using PowerShell.
  3. After removing the gateway and the resources you'll be able to delete the Virtual Network. 
  4. And the final step, if you linked the Virtual Network to a Local Network you can now also remove the Local Network (which was referenced by the Virtual Network): 
Enjoy!

No comments: