Can't delete Azure Image - Provisioning Failed (but it did't))

Jason Stoll 6 Reputation points
2021-01-23T18:38:05.287+00:00

Hello

Annoyingly, because i guess i am still being charged for something incorrectly (if they want to waste their resources so be it, but not mine), as the title states, the image from which i created a virtual machine cannot be deleted. The VM is fine, it's live and working well, but Azure thinks it failed provisioning then tells me the machine is live and well. At the bottom are the errors (with some obfuscation).

I tried powershell with force option, that didn't work (but it returned success anyway?). Clearly to get beyind this i just need to mark this vm as ok. Anyway to do that? Alternatively another way forward is microsft just accept they failed and refund any charges from now until i close my account for the forever image.

Thanks for any help or insights.

P.S I tried to create another vm from same image hoping it would succeed and then i'd kill the other and destroy the image, but...same result

1 )Additional error information is available for this virtual machine:
GENERAL
Provisioning state Provisioning failed.
OS Provisioning for VM 'VMNAME' did not finish in the allotted time. However, the VM guest agent was detected running. This suggests the guest OS has not been properly prepared to be used as a VM image (with CreateOption=FromImage). To resolve this issue, either use the VHD as is with CreateOption=Attach or prepare it properly for use as an image:
* Instructions for Windows: https://azure.microsoft.com/documentation/articles/virtual-machines-windows-upload-image/
* Instructions for Linux: https://azure.microsoft.com/documentation/articles/virtual-machines-linux-capture-image/.
OSProvisioningClientError
Provisioning state error code ProvisioningState/failed/OSProvisioningClientError
Guest agent Ready.
GuestAgent is running and processing the extensions.
DISKS
MYDISK_disk1_e29c4606f95b4ee484b2b2bd89ac04ac Provisioning succeeded.

Virtual machine in a failed state?

2) Deployment to resource group 'MYGGROUP' failed.
Additional details from the underlying API that might be helpful: At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.

3) Failed to delete image 'IMAGENAME'. Error: Operation 'Image Delete' is not allowed since the Virtual Machines 'VM' are being provisioned using the Image 'IMAGENAME'.

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,586 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. TravisCragg-MSFT 5,681 Reputation points Microsoft Employee
    2021-01-26T19:09:30.517+00:00

    As the error outlines, If you made this custom image, it is likely that it was not prepared and saved properly to be used as an image. Preparing a image for a VM is another lengthy topic, and in this post I will focus on the VM in the failed state and the image deletion. If you need help with the preparation / diagnosis of image failure let me know!

    For the Failed VM - The error you are getting is due to the 40 minute OS provisioning timeout. This can be due to a number of reasons, but this is caused by the OS not reporting its status to Azure within 40 minutes of deployment. This can be due to a firewall block, agent failure, or image issue.

    Just because the VM shows a failed status, does NOT mean that the VM has failed. It could be up and running, and you can even log into it, but show failed due to the 40 minute timeout. If this is the case, Stop and Start the VM, and make sure that there are no blockers for the agent reporting to Azure. Here is a great article on how to check the status of a VM agent, and troubleshoot why it might not be working.

    If the image was not prepared properly, it is likely that the VM is not up and running. If the VM is not up and running (even with the status of 'failed), you will need to delete the failed VM. Once the failed VM is fully deleted, you will be able to delete the image. Azure will still charge you while your VM is still allocated to hardware, which it possibly is even while in the 'failed' state.

    To go forward, you will need to figure out why the VM failed so that future deployments are not in a similar state, and then either get the VM into a 'running' state, or get the VM deleted. If you need further assistance, please let me know!

    0 comments No comments

  2. Denis Sharkey 0 Reputation points
    2023-08-09T22:18:05.6433333+00:00

    I know this article is old, but there is a work around for this, make a snapshot of the OS Disk, create a disk from the snapshot, delete the VM, Create a new VM with same Name, OS and version (e.g 2012 R2 v1) of VM that is working but showing failed because of the OS timeout, boot the VM and make sure all is OK, then do an OS swap selecting the disk you made from the snapshot, I did this on half a dozen VMs ranging from 2008, 2012, 2016 in a ransomware attack. worked every time, If you leave the VM in the running but timeout OS state, shuts downs and start ups take forever (45 minutes plus) and backs ups wont deploy. after the OS swap all worked great, Had to install VM guest agent manually on VMs, My VMs were all recovered from a backup server from on-prem VHDx and converted to VHD and uploaded to Azure to build the VMs, Guest agents need manual install and plenty of articles out there on how to do that. Denis Sharkey

    0 comments No comments