Unable to Delete NIC and osDisk After Failed Resource Move Between Subscriptions

Wiecek, Jaroslaw 20 Reputation points
2024-12-05T08:49:26.8733333+00:00

I attempted to move a resource group between subscriptions that contained a VM (along with NSG, osDisk, NIC, and public IP) and virtual network resources. The VM was not powered off prior to the move, leading to an error during the operation. As a result, the VM remained in the old subscription while the other resources were transferred to the new one.

After facing issues with the VM, which could not be powered off, I deleted it. However, the NIC and osDisk remain in the new subscription as they are still linked to the deleted VM.

Is there a way to delete the osDisk and NIC?

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
8,195 questions
Azure Resource Mover
Azure Resource Mover
An Azure service used for moving multiple resources between Azure regions.
248 questions
{count} votes

Accepted answer
  1. Prrudram-MSFT 27,486 Reputation points
    2024-12-16T17:35:18.7766667+00:00

    Hello @Wiecek, Jaroslaw

    Thank you for the cooperation and patience with this us while we got this issue fixed. I am summarizing the issue encountered and resolution we have provided. Please accept this as answer and upvote for "Was it helpful". This will in trun help other users with similar issues.

    Issue Definition: Unable to Delete NIC and osDisk After Failed Resource Move Between Subscriptions

    Cause : The VM was not powered off prior to the move, leading to an error during the operation. As a result, the VM remained in the old subscription while the other resources were transferred to the new one. Deletion of these resources in the attempt of cleanup, it landed in stale entries, broken links in the backend.

    Error Message:
    For Nic deletion-

    Remove-AzNetworkInterface: Network Interface /subscriptions/<Sub_ID>/resourceGroups/<RG_name>/providers/Microsoft.Network/networkInterfaces/<NIC_name> is used by existing resource /subscriptions/<Sub_ID>/resourceGroups/<RG_name>/providers/Microsoft.Compute/virtualMachines/<VM_name>. In order to delete the network interface, it must be dissociated from the resource. To learn more, see aka.ms/deletenic.
    StatusCode: 400 ReasonPhrase: Bad Request ErrorCode: NicInUse

    ErrorMessage: Network Interface /subscriptions/<Sub_ID>/resourceGroups/<RG_name>/providers/Microsoft.Network/networkInterfaces/<NIC_name> is used by existing resource /subscriptions/<Sub_ID>/resourceGroups/<RG_name>/providers/Microsoft.Compute/virtualMachines/<VM_name>. In order to delete the network interface, it must be dissociated from the resource. To learn more, see aka.ms/deletenic.

    for osDisk deletion-

    Remove-AzDisk -ResourceGroupName <RG_name> -DiskName <Disk_name> -Force

    Remove-AzDisk: Disk <Disk_name> is attached to VM /subscriptions/<Sub_ID>/resourceGroups/<RG_name>/providers/Microsoft.Compute/virtualMachines/<VM_name>.

    ErrorCode: OperationNotAllowed

    ErrorMessage: Disk <Disk_name> is attached to VM /subscriptions/<Sub_ID>/resourceGroups/<RG_name>/providers/Microsoft.Compute/virtualMachines/<VM_name>.

    StatusCode: 409 ReasonPhrase: Conflict

    Resolution:

    In a scenario like this where the resource deletion fails due to the failure in complete resource migration resulting in the stale entries, users won't be able to force delete those resources like Nic/OSdisk etc., due to broken links or stale entries. Azure product team fixed this in the backend in order to remove those resources.

    If I have resolved your issue, please accept this as answer as a token of appreciation and don't forget to thumbs up for "Was it helpful"!

    1 person found this answer helpful.

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.