cannot delete resource group because of network interface

Don Ruijgrok 21 Reputation points
2020-10-27T14:30:28.967+00:00

I cannot remove resource group because the network interface blocks the deletion of the network security group and the public ip address. The error indicates that the nic is associated with the NSG and the IP address, but when I try to open the NIC, the resource is not found.
How can I delete my resource group and all the resources in it?

ERROR:

{"Error":{"Code":"ResourceGroupDeletionBlocked","Target":null,"Message":"Deletion of resource group '' failed as resources with identifiers 'Microsoft.Network/networkSecurityGroups/main_vmNSG,Microsoft.Network/publicIPAddresses/main_vmPublicIP,Microsoft.Network/virtualNetworks/main_vmVNET' could not be deleted. The provisioning state of the resource group will be rolled back. The tracking Id is '4925b5cb-c51d-4366-a578-e9f760ee3583'. Please check audit logs for more details.","Details":[{"Code":null,"Target":"/subscriptions//resourceGroups//providers/Microsoft.Network/networkSecurityGroups/main_vmNSG","Message":"{\"error\":{\"code\":\"InUseNetworkSecurityGroupCannotBeDeleted\",\"message\":\"Network security group /subscriptions//resourceGroups//providers/Microsoft.Network/networkSecurityGroups/main_vmNSG cannot be deleted because it is in use by the following resources: /subscriptions//resourceGroups//providers/Microsoft.Network/networkInterfaces/main_vmVMNic. In order to delete the Network security group, remove the association with the resource(s). To learn how to do this, see aka.ms/deletensg.\",\"details\":[]}}","Details":null,"AdditionalInfo":null},{"Code":null,"Target":"/subscriptions//resourceGroups//providers/Microsoft.Network/publicIPAddresses/main_vmPublicIP","Message":"{\"error\":{\"code\":\"PublicIPAddressCannotBeDeleted\",\"message\":\"Public IP address /subscriptions//resourceGroups//providers/Microsoft.Network/publicIPAddresses/main_vmPublicIP can not be deleted since it is still allocated to resource /subscriptions//resourceGroups//providers/Microsoft.Network/networkInterfaces/main_vmVMNic/ipConfigurations/ipconfigmain_vm. In order to delete the public IP, disassociate/detach the Public IP address from the resource. To learn how to do this, see aka.ms/deletepublicip.\",\"details\":[]}}","Details":null,"AdditionalInfo":null},{"Code":null,"Target":"/subscriptions//resourceGroups//providers/Microsoft.Network/virtualNetworks/main_vmVNET","Message":"{\"error\":{\"code\":\"InUseSubnetCannotBeDeleted\",\"message\":\"Subnet main_vmSubnet is in use by /subscriptions//resourceGroups/***/providers/Microsoft.Network/networkInterfaces/main_vmVMNic/ipConfigurations/ipconfigmain_vm and cannot be deleted. In order to delete the subnet, delete all the resources within the subnet. See aka.ms/deletesubnet.\",\"details\":[]}}","Details":null,"AdditionalInfo":null}],"AdditionalInfo":null}}

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
9,013 questions
0 comments No comments
{count} votes

Accepted answer
  1. ChristopherW-MSFT 1,681 Reputation points
    2020-10-27T18:05:58.737+00:00

    Hi @Don Ruijgrok -

    If the Network Interface still shows up in your Resource Group, you can check the Network Security Group it was attached to 'main_vmNSG' and review the 'Network Interfaces' tab. If there are any Interfaces in here, you'll need to Dissociate them.

    If you don't see that it has an Association with any Network Interface, then you can force Update the Network Interface with Azure CLI, PowerShell, or through Resources.Azure.com

    Using Azure Cloud Shell:

    Using Resources.Azure.com, you'll need to find the Network Interface through Subscriptions > (Subscription Name) > resourceGroups > (ResourceGroup Name) > providers > Microsoft.Network > networkInterfaces > (Interface Name)
    Edit then PUT to force the resource to update with Azure if it's stuck in a deletion, or updating state.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.