Unable to Delete Azure Virtual Network

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