Unable to Delete Azure Virtual Network

%3CLINGO-SUB%20id%3D%22lingo-sub-151553%22%20slang%3D%22en-US%22%3EUnable%20to%20Delete%20Azure%20Virtual%20Network%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-151553%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20out%20of%20ideas%2C%20in%20my%20entire%20subscription%2C%20I%20have%201%20x%20Resource%20Group%2C%20and%201%20x%20Virtual%20Network%20(Classic).%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI'm%20trying%20to%20delete%20the%20VNET%20so%20I%20can%20delete%20the%20Resource%20Group%2C%20problem%20is%20I%20am%20receiving%20this%20error%3C%2FP%3E%0A%3CP%3E%22%3CSPAN%3EThis%20virtual%20network%20is%20in%20use%20and%20cannot%20be%20deleted.%20If%20you%20recently%20deleted%20resources%2C%20it%20might%20take%20some%20time%20to%20update%20the%20virtual%20network%22.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EWhen%20I%20run%20Get-AzureRmResource%20the%20only%20entry%20I%20get%20is%20of%20the%20Virtual%20Network%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EName%20%3A%20GT-Lab-VNET%3CBR%20%2F%3EResourceId%20%3A%20%2Fsubscriptions%2Faa5ce18d-aaef-47df-8a79-6640fe0f0693%2FresourceGroups%2FGT-Lab%2Fproviders%2FMicrosoft.ClassicNetwork%2FvirtualNetworks%2FGT-Lab-VNET%3CBR%20%2F%3EResourceName%20%3A%20GT-Lab-VNET%3CBR%20%2F%3EResourceType%20%3A%20Microsoft.ClassicNetwork%2FvirtualNetworks%3CBR%20%2F%3EResourceGroupName%20%3A%20GT-Lab%3CBR%20%2F%3ELocation%20%3A%20australiasoutheast%3CBR%20%2F%3ESubscriptionId%20%3A%20aa5ce18d-aaef-47df-8a79-6640fe0f0693%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EGet-AzureRmVirtualNetwork%20does%20not%20appear%20to%20list%20the%20VNET%2C%20possibly%20because%20it%20appears%20to%20be%20a%20%3C%2FSPAN%3E%3CSPAN%3Eclassic%20resource.%26nbsp%3B%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EI%20checked%2C%20in%20the%20Azure%20ARM%20Portal%2C%20there%20is%20no%20Address%26nbsp%3BSpace%20or%20Subnet%20configured.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CBR%20%2F%3EI%22m%20not%20sure%20how%20else%20I%20can%20delete%20the%20VNET.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-151553%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EVirtual%20Network%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-152256%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20Delete%20Azure%20Virtual%20Network%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-152256%22%20slang%3D%22en-US%22%3E%3CP%3EInitially%20I%20thought%20it%20was%20ADDS%20as%20well%2C%20however%20I%20checked%20the%20ADDS%20blade%2C%20and%20it%20lists%20nothing.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-152180%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20Delete%20Azure%20Virtual%20Network%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-152180%22%20slang%3D%22en-US%22%3E%3CP%3EAt%20this%20point%20it%20could%20be%20multiple%20things%2C%20below%20is%20an%20article%20that%20goes%20over%20a%20few%20things%20to%20check.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fvirtual-network%2Fvirtual-network-troubleshoot-cannot-delete-vnet%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fvirtual-network%2Fvirtual-network-troubleshoot-cannot-delete-vnet%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EMost%20times%20its%20the%20Azure%20AD%20Domain%20Service%2C%20people%20tend%20to%20forget%20about%20it%20because%20it%20is%20not%20really%20setup%20on%20the%20virtual%20network.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-152103%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20Delete%20Azure%20Virtual%20Network%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-152103%22%20slang%3D%22en-US%22%3E%3CP%3EAs%20far%20as%20I%20am%20aware%2C%20every%20single%20thing%20has%20been%20deleted%20from%20the%20subscription%20leaving%20this%20VNET.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20have%20done%20the%20network%20config%20export%2C%20removed%20the%20DNS%2C%20and%20that%20was%20successful%20however%20I%20am%20still%20prevented%20from%20deleting%20the%20VNET.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3E%3CNETWORKCONFIGURATION%20xsd%3D%22%26quot%3B%26lt%3BA%22%20href%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%3CA%20href%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%3C%2FA%3E%22%20xmlns%3Axsi%3D%22%3CA%20href%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%3C%2FA%3E%22%20xmlns%3D%22%3CA%20href%3D%22http%3A%2F%2Fschemas.microsoft.com%2FServiceHosting%2F2011%2F07%2FNetworkConfiguration%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttp%3A%2F%2Fschemas.microsoft.com%2FServiceHosting%2F2011%2F07%2FNetworkConfiguration%3C%2FA%3E%22%26gt%3B%3CBR%20%2F%3E%20%3CVIRTUALNETWORKCONFIGURATION%3E%3CBR%20%2F%3E%20%3CDNS%3E%3C%2FDNS%3E%3CBR%20%2F%3E%20%3CVIRTUALNETWORKSITES%3E%3CBR%20%2F%3E%20%3CVIRTUALNETWORKSITE%20name%3D%22%26quot%3BGroup%22%20gt-lab%3D%22%22%20gt-lab-vnet%3D%22%22%3E%3CBR%20%2F%3E%20%3CADDRESSSPACE%3E%3CBR%20%2F%3E%20%3CADDRESSPREFIX%3E10.0.0.0%2F24%3C%2FADDRESSPREFIX%3E%3CBR%20%2F%3E%20%3C%2FADDRESSSPACE%3E%3CBR%20%2F%3E%20%3CSUBNETS%3E%3CBR%20%2F%3E%20%3CSUBNET%20name%3D%22%26quot%3BDefault%26quot%3B%22%3E%3CBR%20%2F%3E%20%3CADDRESSPREFIX%3E10.0.0.0%2F24%3C%2FADDRESSPREFIX%3E%3CBR%20%2F%3E%20%3C%2FSUBNET%3E%3CBR%20%2F%3E%20%3C%2FSUBNETS%3E%3CBR%20%2F%3E%20%3C%2FVIRTUALNETWORKSITE%3E%3CBR%20%2F%3E%20%3C%2FVIRTUALNETWORKSITES%3E%3CBR%20%2F%3E%20%3C%2FVIRTUALNETWORKCONFIGURATION%3E%3CBR%20%2F%3E%3C%2FNETWORKCONFIGURATION%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20wished%20I%20still%20had%20access%20to%20the%20ASM%20Portal%2C%20right%20now%20I%20keep%20getting%20redirected%20to%20the%20ARM%20Portal.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERemove-AzureVNetConfig%20%3A%20BadRequest%20%3A%20Cannot%20delete%20or%20modify%20virtual%20network%20while%20in%20use%20'Group%20GT-Lab%20GT-Lab-VNET'.%3CBR%20%2F%3EAt%20line%3A1%20char%3A1%3CBR%20%2F%3E%2B%20Remove-AzureVNetConfig%3CBR%20%2F%3E%2B%20~~~~~~~~~~~~~~~~~~~~~~%3CBR%20%2F%3E%20%2B%20CategoryInfo%20%3A%20CloseError%3A%20(%3A)%20%5BRemove-AzureVNetConfig%5D%2C%20ComputeCloudException%3CBR%20%2F%3E%20%2B%20FullyQualifiedErrorId%20%3A%20Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.RemoveAzureVNetConfigCommand%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWorst%20thing%20is%20that%20I%20am%20unable%20to%20get%20support%20for%20this%20because%20its%20an%20MSDN%20Subcription.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-152101%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20Delete%20Azure%20Virtual%20Network%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-152101%22%20slang%3D%22en-US%22%3E%3CP%3EFrom%20you%20output%20it%20says%20VNet%20is%20in%20use%20and%20i%20see%20a%20DNS%20Server%20entry%2C%20not%20sure%20if%20thats%20the%20only%20thing%20using%20VNet.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EDid%20you%20have%20Azure%20AD%20Domain%20Service%20on%26nbsp%3Bthat%20VNet%3F%3C%2FP%3E%0A%3CP%3EDo%20you%20still%20have%20access%20to%20the%20legacy%20portal%26nbsp%3Bmanage.windowsazure.com%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20have%20access%20you%20will%20need%20to%20clear%20up%20the%20VNet%20from%20there.%20If%20you%20don't%20have%20access%20you%20can%20try%20exporting%20the%20VNet%20configuration%2C%20removing%20the%20DNS%20configuration%20and%20then%20import%20configuration%20back.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3EGet-AzureVNetConfig%20-ExportToFile%20%22c%3A%5Ctemp%5CMyAzNets.netcfg%22%3C%2FPRE%3E%0A%3CP%3EEdit%20file%20to%20remove%20DNS%2C%20the%20update%20configuration%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3ESet-AzureVNetConfig%26nbsp%3B%20-ConfigurationPath%20%22c%3A%5Ctemp%5CMyAzNets.netcfg%22%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-152099%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20Delete%20Azure%20Virtual%20Network%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-152099%22%20slang%3D%22en-US%22%3E%3CP%3EYou're%20right%2C%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAddressSpacePrefixes%20%3A%20%7B10.0.0.0%2F24%7D%3CBR%20%2F%3ELocation%20%3A%20Australia%20Southeast%3CBR%20%2F%3EAffinityGroup%20%3A%20%3CBR%20%2F%3EDnsServers%20%3A%20%7B10.0.0.5%7D%3CBR%20%2F%3EGatewayProfile%20%3A%20%3CBR%20%2F%3EGatewaySites%20%3A%20%7B%7D%3CBR%20%2F%3EId%20%3A%203a659ee2-f4f8-4e4d-a448-b467ffa95ec8%3CBR%20%2F%3EInUse%20%3A%20True%3CBR%20%2F%3ELabel%20%3A%20%3CBR%20%2F%3EMigrationState%20%3A%20%3CBR%20%2F%3EName%20%3A%20Group%20GT-Lab%20GT-Lab-VNET%3CBR%20%2F%3EState%20%3A%20Created%3CBR%20%2F%3ESubnets%20%3A%20%7BDefault%7D%3CBR%20%2F%3EOperationDescription%20%3A%20Get-AzureVNetSite%3CBR%20%2F%3EOperationId%20%3A%2038c55e74-a3ec-7b20-b4aa-e5434b675eda%3CBR%20%2F%3EOperationStatus%20%3A%20Succeeded%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHow%20do%20I%20delete%2Fremove%20this%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-151574%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20Delete%20Azure%20Virtual%20Network%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-151574%22%20slang%3D%22en-US%22%3E%3CP%3EThere%20might%20be%20some%20classic%20resource%20still%20tied%20to%20the%20VNet%20not%20visible%20in%20the%20new%20portal.%20You%20should%20be%20able%20to%20check%20the%20virtual%20network%20using%20PowerShell%20but%20the%20command%20you%20are%20using%20is%20not%20for%20classic%20resources.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CPRE%3EAdd-AzureAccount%0AGet-AzureVNetSite%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20813px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F27869iE8B992922A1466F2%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%2220180201-224531.png%22%20title%3D%2220180201-224531.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

I'm out of ideas, in my entire subscription, I have 1 x Resource Group, and 1 x Virtual Network (Classic). 

 

I'm trying to delete the VNET so I can delete the Resource Group, problem is I am receiving this error

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

 

When I run Get-AzureRmResource the only entry I get is of the Virtual Network

 

Name : GT-Lab-VNET
ResourceId : /subscriptions/aa5ce18d-aaef-47df-8a79-6640fe0f0693/resourceGroups/GT-Lab/providers/Microsoft.ClassicNetwork/virtualNetworks/GT-Lab-VNET
ResourceName : GT-Lab-VNET
ResourceType : Microsoft.ClassicNetwork/virtualNetworks
ResourceGroupName : GT-Lab
Location : australiasoutheast
SubscriptionId : aa5ce18d-aaef-47df-8a79-6640fe0f0693

 

Get-AzureRmVirtualNetwork does not appear to list the VNET, possibly because it appears to be a classic resource. 

 

I checked, in the Azure ARM Portal, there is no Address Space or Subnet configured. 


I"m not sure how else I can delete the VNET. 

6 Replies

There might be some classic resource still tied to the VNet not visible in the new portal. You should be able to check the virtual network using PowerShell but the command you are using is not for classic resources.

Add-AzureAccount
Get-AzureVNetSite

 

20180201-224531.png

You're right, 

 

AddressSpacePrefixes : {10.0.0.0/24}
Location : Australia Southeast
AffinityGroup :
DnsServers : {10.0.0.5}
GatewayProfile :
GatewaySites : {}
Id : 3a659ee2-f4f8-4e4d-a448-b467ffa95ec8
InUse : True
Label :
MigrationState :
Name : Group GT-Lab GT-Lab-VNET
State : Created
Subnets : {Default}
OperationDescription : Get-AzureVNetSite
OperationId : 38c55e74-a3ec-7b20-b4aa-e5434b675eda
OperationStatus : Succeeded

 

How do I delete/remove this?

From you output it says VNet is in use and i see a DNS Server entry, not sure if thats the only thing using VNet.

 

Did you have Azure AD Domain Service on that VNet?

Do you still have access to the legacy portal manage.windowsazure.com?

 

If you have access you will need to clear up the VNet from there. If you don't have access you can try exporting the VNet configuration, removing the DNS configuration and then import configuration back.

 

Get-AzureVNetConfig -ExportToFile "c:\temp\MyAzNets.netcfg"

Edit file to remove DNS, the update configuration

 

Set-AzureVNetConfig  -ConfigurationPath "c:\temp\MyAzNets.netcfg"

 

As far as I am aware, every single thing has been deleted from the subscription leaving this VNET. 

 

I have done the network config export, removed the DNS, and that was successful however I am still prevented from deleting the VNET. 

 

<?xml version="1.0" encoding="utf-8"?>
<NetworkConfiguration xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/ServiceHosting/2011/07/NetworkConfiguration">
<VirtualNetworkConfiguration>
<Dns />
<VirtualNetworkSites>
<VirtualNetworkSite name="Group GT-Lab GT-Lab-VNET" Location="Australia Southeast">
<AddressSpace>
<AddressPrefix>10.0.0.0/24</AddressPrefix>
</AddressSpace>
<Subnets>
<Subnet name="Default">
<AddressPrefix>10.0.0.0/24</AddressPrefix>
</Subnet>
</Subnets>
</VirtualNetworkSite>
</VirtualNetworkSites>
</VirtualNetworkConfiguration>
</NetworkConfiguration>

 

I wished I still had access to the ASM Portal, right now I keep getting redirected to the ARM Portal. 

 

Remove-AzureVNetConfig : BadRequest : Cannot delete or modify virtual network while in use 'Group GT-Lab GT-Lab-VNET'.
At line:1 char:1
+ Remove-AzureVNetConfig
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Remove-AzureVNetConfig], ComputeCloudException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.RemoveAzureVNetConfigCommand

 

Worst thing is that I am unable to get support for this because its an MSDN Subcription. 

 

At this point it could be multiple things, below is an article that goes over a few things to check.

 

https://docs.microsoft.com/en-us/azure/virtual-network/virtual-network-troubleshoot-cannot-delete-vn...

 

Most times its the Azure AD Domain Service, people tend to forget about it because it is not really setup on the virtual network.

Initially I thought it was ADDS as well, however I checked the ADDS blade, and it lists nothing.