Cannot Remove resource group and all its resources

Alex Wang 1 Reputation point
2020-08-06T00:39:28.807+00:00

HI all,
When I try to delete my resource group and all its resource. I encounter the following error message.

Failed to delete resource group win10: Deletion of resource group 'win10' failed as resources with identifiers 'Microsoft.Network/networkSecurityGroups/win10-nsg,Microsoft.Network/networkInterfaces/win10761,Microsoft.Compute/disks/win10_OsDisk_1_5b8e13e3988b4ed8a38250f8c3f5ff38,Microsoft.Network/publicIPAddresses/win10-ip,Microsoft.Network/virtualNetworks/win10-vnet' could not be deleted. The provisioning state of the resource group will be rolled back. The tracking Id is 'bcb96ed3-4cc2-4474-973d-57184a2c9faf'. Please check audit logs for more details. (Code: ResourceGroupDeletionBlocked) Network security group /subscriptions/0d8cfcb6-1220-4779-93ab-5568bc832ec3/resourceGroups/win10/providers/Microsoft.Network/networkSecurityGroups/win10-nsg cannot be deleted because it is in use by the following resources: /subscriptions/0d8cfcb6-1220-4779-93ab-5568bc832ec3/resourceGroups/win10/providers/Microsoft.Network/networkInterfaces/win10761. 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. (Code: InUseNetworkSecurityGroupCannotBeDeleted, Target: /subscriptions/0d8cfcb6-1220-4779-93ab-5568bc832ec3/resourceGroups/win10/providers/Microsoft.Network/networkSecurityGroups/win10-nsg) Network Interface /subscriptions/0d8cfcb6-1220-4779-93ab-5568bc832ec3/resourceGroups/win10/providers/Microsoft.Network/networkInterfaces/win10761 is used by existing resource /subscriptions/0d8cfcb6-1220-4779-93ab-5568bc832ec3/resourceGroups/win10/providers/Microsoft.Compute/virtualMachines/win10. In order to delete the network interface, it must be dissociated from the resource. To learn more, see aka.ms/deletenic. (Code: NicInUse, Target: /subscriptions/0d8cfcb6-1220-4779-93ab-5568bc832ec3/resourceGroups/win10/providers/Microsoft.Network/networkInterfaces/win10761) Disk win10_OsDisk_1_5b8e13e3988b4ed8a38250f8c3f5ff38 is attached to VM /subscriptions/0d8cfcb6-1220-4779-93ab-5568bc832ec3/resourceGroups/win10/providers/Microsoft.Compute/virtualMachines/win10. (Code: OperationNotAllowed, Target: /subscriptions/0d8cfcb6-1220-4779-93ab-5568bc832ec3/resourceGroups/WIN10/providers/Microsoft.Compute/disks/win10_OsDisk_1_5b8e13e3988b4ed8a38250f8c3f5ff38) Public IP address /subscriptions/0d8cfcb6-1220-4779-93ab-5568bc832ec3/resourceGroups/win10/providers/Microsoft.Network/publicIPAddresses/win10-ip can not be deleted since it is still allocated to resource /subscriptions/0d8cfcb6-1220-4779-93ab-5568bc832ec3/resourceGroups/win10/providers/Microsoft.Network/networkInterfaces/win10761/ipConfigurations/ipconfig1. 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. (Code: PublicIPAddressCannotBeDeleted, Target: /subscriptions/0d8cfcb6-1220-4779-93ab-5568bc832ec3/resourceGroups/win10/providers/Microsoft.Network/publicIPAddresses/win10-ip) Subnet default is in use by /subscriptions/0d8cfcb6-1220-4779-93ab-5568bc832ec3/resourceGroups/win10/providers/Microsoft.Network/networkInterfaces/win10761/ipConfigurations/ipconfig1 and cannot be deleted. In order to delete the subnet, delete all the resources within the subnet. See aka.ms/deletesubnet. (Code: InUseSubnetCannotBeDeleted, Target: /subscriptions/0d8cfcb6-1220-4779-93ab-5568bc832ec3/resourceGroups/win10/providers/Microsoft.Network/virtualNetworks/win10-vnet)

regards,
Alex

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,157 questions
{count} votes

3 answers

Sort by: Most helpful
  1. KarishmaTiwari-MSFT 18,522 Reputation points Microsoft Employee
    2020-08-06T01:07:32.48+00:00

    You can delete a network interface as long as it's not attached to a virtual machine. If a network interface is attached to a virtual machine, you must first place the virtual machine in the stopped (deallocated) state, then detach the network interface from the virtual machine.
    To detach a network interface from a virtual machine, complete the steps in Detach a network interface from a virtual machine.

    You cannot detach a network interface from a virtual machine if it's the only network interface attached to the virtual machine however. A virtual machine must always have at least one network interface attached to it. Deleting a virtual machine detaches all network interfaces attached to it, but does not delete the network interfaces.

    Once detached from VM, delete the NIC by following these steps:

    -In the box that contains the text Search resources at the top of the Azure portal, type network interfaces. When network interfaces appear in the search results, select it.
    -Select the network interface in the list that you want to delete.
    -Under Overview Select Delete.
    -Select Yes to confirm deletion of the network interface.
    -When you delete a network interface, any MAC or IP addresses assigned to it are released.

    "Please accept as answer if it helped, so that it can help others in the community facing similar issues."


  2. Alex Wang 1 Reputation point
    2020-08-06T05:51:31.55+00:00

    @KarishmaTiwari-MSFT

    Thanks a lot for the reply. The problem is my VM is not in "unknown status". and when I click on it , it did not show anything. so I cannot even remove the interface from the VM as the VM is in unknown status.
    Is there is way to just force delete the whole resource group include the resources in it? or force delete the VM?

    regards,
    Alex

    0 comments No comments

  3. Alex Wang 1 Reputation point
    2020-08-06T07:01:52.887+00:00

    It looks like someone from MS Azure team fixed the portal cannot delete resource and resource group for me.
    I can now delete the VM, and all its resources and also resource group.

    thanks a lot for your support and service.

    regards,
    Alex