Hi, I am Henry, I will help with this
Since this is a Hyper-V VM migrated to Azure, here's a structured approach to troubleshoot and fix this:
Immediate First Step (If you haven't already):
Do NOT delete the original on-premises VM until you have the Azure VM working and fully tested.
Snapshot/Backup the OS Disk in Azure: Before making significant changes, if possible, take a snapshot of the managed disk in Azure. This gives you a rollback point. (Go to the VM's Disks blade, click the OS disk, then "Create snapshot").
Troubleshooting Steps:
- Verify VM Generation:
- Was your on-premises Hyper-V VM Generation 1 or Generation 2?
- Ensure the Azure VM size you selected supports the same generation. Most modern Azure VM sizes support Gen2, but older ones might be Gen1 only. If there's a mismatch (e.g., on-prem Gen2 migrated to an Azure Gen1 VM size, or vice-versa), it won't boot. You might need to recreate the VM with the correct generation/size.
- Use Azure VM Repair Tools (Recommended Method for BCD issues):
This involves attaching the OS disk of the problematic VM to a temporary "rescue" or "repair" VM.
- Create a Repair VM:
- Deploy a new Windows Server VM in Azure (same region, ideally same OS version or newer). This will be your repair VM.
- Detach the OS Disk:
- Stop (deallocate) your non-booting VM.
- Go to its "Disks" blade, select the OS disk, and click "Swap OS disk." This isn't what you want directly, but from here you can note the disk name. Or, you can directly go to "Disks" in Azure portal, find the OS disk of your problematic VM.
- Alternatively, delete the problematic VM but keep its OS disk.
- Attach the OS Disk to the Repair VM:
- Go to the Disks blade of your Repair VM.
- Click "Add data disk" and attach the OS disk of your problematic VM as a data disk.
- Connect to the Repair VM and Repair BCD:
- RDP into the Repair VM.
- Open Disk Management (diskmgmt.msc). The attached disk should appear. It might be offline; if so, right-click and bring it online. Note the drive letters assigned to the partitions of the attached OS disk (e.g., E: for the Windows partition, F: for the System/EFI partition if it's visible).
- Open an elevated Command Prompt. Run
chkdsk E: /f /r
- Attempt to repair the BCD:
Let's assume the Windows partition of the attached disk is E:\Windows.- For BIOS-based (Generation 1) VMs:
bootrec /fixmbr
bootrec /fixboot
bootrec /scanos
bootrec /rebuildbcd (Answer 'Y' to add to boot list)
- If bootrec /fixboot fails, and /rebuildbcd doesn't find an OS, try:
bcdboot E:\Windows /s E:
(Sometimes the system partition isn't separate on Gen1, so E: might be correct for /s parameter if that's where boot files are). - For UEFI-based (Generation 2) VMs:
You need to identify the EFI System Partition (ESP) on the attached disk. It's usually a small FAT32 partition. Assign it a letter if it doesn't have one (e.g., S:) using diskpart:list disk
select disk X (X is the disk number of the attached OS disk)
list partition
select partition Y (Y is the ESP partition number)
assign letter=S
exit
Then in Command Prompt:bcdboot E:\Windows /s S: /f UEFI
- Detach the Disk and Reattach to Original VM:
- Shutdown the Repair VM.
- Detach the data disk (the problematic OS disk).
- If you deleted the original VM, recreate it using the repaired OS disk ("Create a VM" -> "All services" -> "Disks" -> select your disk -> "Create VM").
- If you just stopped the original VM and detached its disk, you might need to use PowerShell/CLI to reattach the correct OS disk or "Swap OS disk" in the portal to point back to the repaired one.
- For BIOS-based (Generation 1) VMs:
- Check for Generalized vs. Specialized Disk Issues:
- When migrating, especially with tools like Azure Migrate, the VM should be generalized (sysprepped) if it's intended to be a new "template" VM. If it was a specialized migration (meant to be an exact copy retaining its identity), sysprep is not run.
- An improperly generalized image or issues during the generalization process can cause boot failures.
- If you manually uploaded a VHD, ensure it was prepared correctly (e.g., if specialized, certain registry keys for hardware might need to be cleared; if generalized, it needs sysprep /generalize /oobe).
- Use Serial Console for Basic Checks/Commands (If VM gets far enough):
- In the Azure portal, for your non-booting VM, go to "Serial console" (under Support + Troubleshooting).
- You might be able to access Special Administration Console (SAC) if Windows starts loading partially.
- From SAC, you can try chkdsk, launch a CMD session (requires credentials), and try basic bootrec commands, but the repair VM method is more robust.
- Azure VM Redeploy:
- On the VM's blade in Azure, go to "Redeploy + reapply" then "Redeploy." This moves the VM to a new host in the Azure infrastructure, which can sometimes resolve issues caused by the underlying host. It's a less invasive step to try. Remember to be patient, as detaching/attaching disks and running checks can take some time.