Can't delete Azure VM in failed state ("internal execution error")

Andreas Kerkau 1 Reputation point
2022-08-06T08:52:37.127+00:00

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 machine is stopped.
  • "The last operation performed on this VM failed."
  • When trying to re-delete the VM (with or without checking "Apply force delete" but not touching the disks) it fails with "ResourceOperationFailure": "An internal execution error occurred. Please retry later."

The datadisks (which I need to preserve) are in state "8 of 8 data disks pending detachment".

Do you have any advice?

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
9,018 questions
Azure Disk Storage
Azure Disk Storage
A high-performance, durable block storage designed to be used with Azure Virtual Machines and Azure VMware Solution.
668 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Jackson Martins 10,606 Reputation points MVP Volunteer Moderator
    2022-08-06T09:37:13.543+00:00

    Hi @Andreas Kerkau

    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


  2. Andreas Kerkau 1 Reputation point
    2022-08-07T08:44:49.47+00:00

    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.


  3. srbhatta-MSFT 8,586 Reputation points Microsoft Employee
    2022-08-08T05:56:51.803+00:00

    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.

    0 comments No comments

  4. Uros Opaka 1 Reputation point
    2022-08-11T12:46:31.81+00:00

    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?


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.