Do you have some old Windows Server Azure VMs that need an upgrade to a newer OS? Good news! You can perform this upgrade directly in Azure. In this tutorial, we’ll guide you through the process of performing an in-place upgrade for VMs running Windows Server in Azure.
Introduction
Today, we’ll walk through the process of doing an in-place upgrade for a Windows Server VM in Azure.
Supported Versions
According to Microsoft documentation, in-place upgrades are currently supported for upgrading to:
- Windows Server 2012
- Windows Server 2016
- Windows Server 2019
- Windows Server 2022
Steps for In-Place Upgrade
1. Taking a Snapshot
To ensure a safe upgrade, the first step is taking a snapshot of your VM. Follow these instructions:
- Navigate to the Disks section in your Azure portal.
- Open the OS disk for the VM you are upgrading.
- Create a snapshot and give it a relevant name. For example, “VM1 backup disk”.
- Click Create and wait for the deployment to complete.
2. Creating Upgrade Media
Next, we need to create the upgrade media using a PowerShell script from the Microsoft documentation:
- Copy the template PowerShell script from the Microsoft documentation (https://learn.microsoft.com/en-us/azure/virtual-machines/windows-in-place-upgrade#powershell-script).
- Go to the Azure portal and open the Cloud Shell.
- Select Editor, if you are using the new cloud shell UI you may get an error saying that you must use classic cloud shell to use editor. If so, go ahead and switch and then select the Editor icon from the classic experience.
- Paste the script into the Cloud Shell editor, ensuring it’s saved with the
.ps1
extension, for example, “2022upgrademedia.ps1”. - Edit the script to match your specific parameters like region and SKU name, if necessary.
- Save the script and run it to create the upgrade media managed disk.
3. Attaching the Upgrade Media to VM
After creating the upgrade media, attach it to your VM:
- Go back to the VM in the Azure portal.
- Navigate to Disks and select Attach existing disk.
- Choose the newly created Windows Server 2022 upgrade disk and apply the changes.
4. Running the In-Place Upgrade
Now, we perform the actual in-place upgrade:
- Remote into the VM using RDP, Bastion, or any other remote access tool.
- Open PowerShell with administrator privileges.
- Change directory to the upgrade media drive (e.g.,
E:
drive) and the subfolder within the media drive that contains the setup executable. - Use the PowerShell command provided in the documentation to start the upgrade process:
.\setup.exe /auto upgrade /dynamicupdate disable
- Select the desired experience. If you prefer a GUI version, choose “Windows Server 2022 DataCenter with Desktop Experience”.
5. Completing the Upgrade
After the upgrade process completes:
- Remote back into the VM and verify the OS upgrade by checking the Server Manager.
- Ensure it displays “Windows Server 2022 DataCenter”.
6. Cleaning Up
The final steps involve cleaning up by removing extra resources:
- Detach the upgrade disk from the VM.
- Delete both the upgrade disk and the snapshot resources.
And that’s it! You’ve successfully performed an in-place upgrade of your Windows Server VM in Azure. This process helps keep your infrastructure up-to-date without having to deploy new VMs or transfer data manually.
For more information and detailed steps, you may refer to Microsoft’s official documentation. Happy upgrading!