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:

  1. Navigate to the Disks section in your Azure portal.
  2. Open the OS disk for the VM you are upgrading.
  3. Create a snapshot and give it a relevant name. For example, “VM1 backup disk”.
  4. 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:

  1. Copy the template PowerShell script from the Microsoft documentation (https://learn.microsoft.com/en-us/azure/virtual-machines/windows-in-place-upgrade#powershell-script).
  2. Go to the Azure portal and open the Cloud Shell.
  3. 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.
  4. Paste the script into the Cloud Shell editor, ensuring it’s saved with the .ps1 extension, for example, “2022upgrademedia.ps1”.
  5. Edit the script to match your specific parameters like region and SKU name, if necessary.
  6. 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:

  1. Go back to the VM in the Azure portal.
  2. Navigate to Disks and select Attach existing disk.
  3. 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:

  1. Remote into the VM using RDP, Bastion, or any other remote access tool.
  2. Open PowerShell with administrator privileges.
  3. Change directory to the upgrade media drive (e.g., E: drive) and the subfolder within the media drive that contains the setup executable.
  4. Use the PowerShell command provided in the documentation to start the upgrade process: .\setup.exe /auto upgrade /dynamicupdate disable
  5. 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:

  1. Remote back into the VM and verify the OS upgrade by checking the Server Manager.
  2. Ensure it displays “Windows Server 2022 DataCenter”.

6. Cleaning Up

The final steps involve cleaning up by removing extra resources:

  1. Detach the upgrade disk from the VM.
  2. 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!