Search code examples
azurevirtual-machinereboothour

Azure VM reboots exactly 1 hour after startup


Problem:
All VMs created from our custom images (VHD files from a Storage Account), all reboot exactly 1 hour after first starting up in Azure.

Symptoms:

  • After the 1-hour reboot, the VM will remain UP consistently from that point.
  • However, if you stop and de-allocate the VM, then start it... it will reboot again after 1 hour.
  • The only hint of evidence from within the VM, is a shutdown event from svchost.exe, without any details or nearby events that help narrow the root cause.

Steps to reproduce:
1- In local Hyper-V, create and setup a Win10 VM. Optionally customize the wallpaper as you see fit. Don't sysprep.

2- Shutdown the local VM, and using 'Edit Disk', convert it to a fixed-size VHD format.

3- Upload the VHD to your Azure Storage Account.

4- Register an image, pointing to the VHD uploaded in the storage blob.

5- Deploy a VM from that image. After 1 hour from startup, it will unexpectedly reboot.


Solution

  • To someone with more Azure experience, the problem is obvious-- "Images" in Azure implies the VHD is a 'generalized image', an image that has had sysprep performed.

    If you're creating a VM based off a non-generalized VHD, you need to do a two-step process:
    1- Create a new Disk, and base it off the VHD from your Storage Account.
    2- From the Disk, choose "Create VM".

    In our situation, the VHD is highly specific and customized, for kiosk type operation. Running sysprep to generalize is not an option that allows us to retain all the configuration and customization that have been applied.

    Thus if you're in a similar boat, you can create a Disk from the VHD, then create a VM using that Disk. No more unexpected reboots after 1-hour.

    For reference, official documentation on creating a VM from a Disk (or Disk Snapshot):
    https://learn.microsoft.com/en-us/azure/virtual-machines/windows/create-vm-specialized-portal

    For reference, steps to generalize a VHD to be used as an Azure "Image":
    https://learn.microsoft.com/en-us/azure/virtual-machines/windows/prepare-for-upload-vhd-image