You can update the delete behavior on an existing VM to keep os disk and try to use azure cli with force delete,
Reference: https://learn.microsoft.com/en-us/azure/virtual-machines/delete?tabs=cli2%2Cpowershell3%2Cportal4
Best Regards
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I've got a VM that got stuck in state "Updating" during scaling to larger size. The agent stopped running (or wasn't reachable) and some disks were pending detachment.
I then tried to delete the VM. The current state (after several retries in the last 24 hours) is:
The datadisks (which I need to preserve) are in state "8 of 8 data disks pending detachment".
Do you have any advice?
You can update the delete behavior on an existing VM to keep os disk and try to use azure cli with force delete,
Reference: https://learn.microsoft.com/en-us/azure/virtual-machines/delete?tabs=cli2%2Cpowershell3%2Cportal4
Best Regards
Finally, the deletion succeeded. I used the variant with -ForceDeletion $true for the n-th time and now it worked.
Seemingly, something behind the scenes came back into place... days after the issue occured. Well.
Hello @Andreas Kerkau ,
Welcome to Microsoft QnA.
I came across this thread now and I see you had faced issues with deleting your VM.
To add to what Martin had suggested above (using force deletion), I am also sharing a couple of steps below which can help to resolve these kinds of issues going forward in future.
When a VM is in a "failed" state, it is reflective of the result of the last operation but it does not necessarily mean the VM is failed and not working. So, this means that the last operation (delete operation in this case) on your VM is failing, which is why the VM is in failed state.
Try to update the VM state by running the below command and see if the VM comes back to normal state. If it comes back to healthy state, then any operation on the VM should be successful.
az vm update -n <VMName> -g <ResourceGroupname>
Also, in your case, we could see that the VM had been marked for deletion, in such cases even after updating the VM (using az vm update) command, and force deleting using Powershell, you see no luck in deleting them successfully, please do get in touch with us or our Support Team, and they will be able to check the backend logs and help further in deleting the VM. Thank You.
-------------------------------
If the information is helpful, please "accept as answer" so that the relevancy of this post increases.
Hi I am having the same issue, so I have deployed with bicep three servers with image from market place, something went wrong, VMs are in failed state, and I cannot delete the VMs, error is:
An error occurred while deleting virtual machine and/or any selected resource(s) associated with it. Error: 'Operation 'Update VM' is not allowed on VM since the VM is marked for deletion. You can only retry the Delete operation (or wait for an ongoing one to complete).'
I tried with -force parameters, from powershell etc, but nothing works, how can I resolve this?