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"!