In-place upgrade for VMs running Windows Server in Azure
An in-place upgrade allows you to go from an older operating system to a newer one while keeping your settings, server roles, and data intact. This article teaches you how to move your Azure VMs to a later version of Windows Server using an in-place upgrade. Currently, upgrading to Windows Server 2016, Windows Server 2019 and Windows Server 2022 are supported.
Before you begin an in-place upgrade:
Review the upgrade requirements for the target operating system:
Upgrade options for Windows Server 2016 from Windows Server 2012 or Windows Server 2012 R2
Upgrade options for Windows Server 2019 from Windows Server 2012 R2 or Windows Server 2016
Upgrade options for Windows Server 2022 from Windows Server 2016 or Windows Server 2019
Verify the operating system disk has enough free space to perform the in-place upgrade. If additional space is needed follow these steps to expand the operating system disk attached to the VM.
Disable antivirus and anti-spyware software and firewalls. These types of software can conflict with the upgrade process. Re-enable antivirus and anti-spyware software and firewalls after the upgrade is completed.
Windows versions not yet supported for in-place upgrade
For the following versions, consider using the workaround later in this article:
- Windows Server 2008 R2 Datacenter
- Windows Server 2008 R2 Standard
Upgrade VM to volume license (KMS server activation)
The upgrade media provided by Azure requires the VM to be configured for Windows Server volume licensing. This is the default behavior for any Windows Server VM that was installed from a generalized image in Azure. If the VM was imported into Azure, then it may need to be converted to volume licensing to use the upgrade media provided by Azure. To confirm the VM is configured for volume license activation follow these steps to configure the appropriate KMS client setup key. If the activation configuration was changed, then follow these steps to verify connectivity to Azure KMS service.
Upgrade to Managed Disks
The in-place upgrade process requires the use of Managed Disks on the VM to be upgraded. Most VMs in Azure are using Managed Disks, and retirement for unmanaged disks support was announced in November of 2022. If the VM is currently using unmanaged disks, then follow these steps to migrate to Managed Disks.
Create snapshot of the operating system disk
We recommend that you create a snapshot of your operating system disk and any data disks before starting the in-place upgrade process. This enables you to revert to the previous state of the VM if anything fails during the in-place upgrade process. To create a snapshot on each disk, follow these steps to create a snapshot of a disk.
Create upgrade media disk
To start an in-place upgrade the upgrade media must be attached to the VM as a Managed Disk. To create the upgrade media, modify the variables in the following PowerShell script for Windows Server 2022. The upgrade media disk can be used to upgrade multiple VMs, but it can only be used to upgrade a single VM at a time. To upgrade multiple VMs simultaneously multiple upgrade disks must be created for each simultaneous upgrade.
Parameter | Definition |
---|---|
resourceGroup | Name of the resource group where the upgrade media Managed Disk will be created. The named resource group is created if it doesn't exist. |
location | Azure region where the upgrade media Managed Disk is created. This must be the same region as the VM to be upgraded. |
zone | Azure zone in the selected region where the upgrade media Managed Disk will be created. This must be the same zone as the VM to be upgraded. For regional VMs (non-zonal) the zone parameter should be "". |
diskName | Name of the Managed Disk that will contain the upgrade media |
sku | Windows Server upgrade media version. This must be either: server2016Upgrade or server2019Upgrade or server2022Upgrade |
PowerShell script
#
# Customer specific parameters
# Resource group of the source VM
$resourceGroup = "WindowsServerUpgrades"
# Location of the source VM
$location = "WestUS2"
# Zone of the source VM, if any
$zone = ""
# Disk name for the that will be created
$diskName = "WindowsServer2022UpgradeDisk"
# Target version for the upgrade - must be either server2022Upgrade or server2019Upgrade
$sku = "server2022Upgrade"
# Common parameters
$publisher = "MicrosoftWindowsServer"
$offer = "WindowsServerUpgrade"
$managedDiskSKU = "Standard_LRS"
#
# Get the latest version of the special (hidden) VM Image from the Azure Marketplace
$versions = Get-AzVMImage -PublisherName $publisher -Location $location -Offer $offer -Skus $sku | sort-object -Descending {[version] $_.Version }
$latestString = $versions[0].Version
# Get the special (hidden) VM Image from the Azure Marketplace by version - the image is used to create a disk to upgrade to the new version
$image = Get-AzVMImage -Location $location `
-PublisherName $publisher `
-Offer $offer `
-Skus $sku `
-Version $latestString
#
# Create Resource Group if it doesn't exist
#
if (-not (Get-AzResourceGroup -Name $resourceGroup -ErrorAction SilentlyContinue)) {
New-AzResourceGroup -Name $resourceGroup -Location $location
}
#
# Create Managed Disk from LUN 0
#
if ($zone){
$diskConfig = New-AzDiskConfig -SkuName $managedDiskSKU `
-CreateOption FromImage `
-Zone $zone `
-Location $location
} else {
$diskConfig = New-AzDiskConfig -SkuName $managedDiskSKU `
-CreateOption FromImage `
-Location $location
}
Set-AzDiskImageReference -Disk $diskConfig -Id $image.Id -Lun 0
New-AzDisk -ResourceGroupName $resourceGroup `
-DiskName $diskName `
-Disk $diskConfig
Attach upgrade media to the VM
Attach the upgrade media for the target Windows Server version to the VM which will be upgraded. This can be done while the VM is in the running or stopped state.
Portal instructions
Sign in to the Azure portal.
Search for and select Virtual machines.
Select a virtual machine to perform the in-place upgrade from the list.
On the Virtual machine page, select Disks.
On the Disks page, select Attach existing disks.
In the drop-down for Disk name, select the name of the upgrade disk created in the previous step.
Select Save to attach the upgrade disk to the VM.
Perform in-place upgrade
To initiate the in-place upgrade the VM must be in the Running
state. Once the VM is in a running state use the following steps to perform the upgrade.
Connect to the VM using RDP or RDP-Bastion.
Determine the drive letter for the upgrade disk (typically E: or F: if there are no other data disks).
Start Windows PowerShell.
Change directory to the only directory on the upgrade disk.
Execute the following command to start the upgrade:
.\setup.exe /auto upgrade /dynamicupdate disable
Select the correct "Upgrade to" image based on the current version and configuration of the VM using the Windows Server upgrade matrix.
During the upgrade process the VM will automatically disconnect from the RDP session. After the VM is disconnected from the RDP session the progress of the upgrade can be monitored through the screenshot functionality available in the Azure portal.
Post upgrade steps
Once the upgrade process has completed successfully the following steps should be taken to clean up any artifacts which were created during the upgrade process:
Delete the snapshots of the OS disk and data disk(s) if they were created.
Delete the upgrade media Managed Disk.
Enable any antivirus, anti-spyware or firewall software that may have been disabled at the start of the upgrade process.
Workaround
For versions of Windows that are not currently supported, create an Azure VM that's running a supported version. And then either migrate the workload (Method 1, preferred), or download and upgrade the VHD of the VM (Method 2). To prevent data loss, back up the Windows 10 VM by using Azure Backup. Or use a third-party backup solution from Azure Marketplace Backup & Recovery.
Method 1: Deploy a newer system and migrate the workload
Create an Azure VM that runs a supported version of the operating system, and then migrate the workload. To do so, you'll use Windows Server migration tools. For instructions to migrate Windows Server roles and features, see Install, use, and remove Windows Server migration tools.
Method 2: Download and upgrade the VHD
- Do an in-place upgrade in a local Hyper-V VM
- Download the VHD of the VM.
- Attach the VHD to a local Hyper-V VM.
- Start the VM.
- Run the in-place upgrade.
- Upload the VHD to Azure. For more information, see Upload a generalized VHD and use it to create new VMs in Azure.
Recover from failure
If the in-place upgrade process failed to complete successfully you can return to the previous version of the VM if snapshots of the operating system disk and data disk(s) were created. To revert the VM to the previous state using snapshots complete the following steps:
Create a new Managed Disk from the OS disk snapshot and each data disk snapshot following the steps in Create a disk from a snapshot making sure to create the disks in the same Availability Zone as the VM if the VM is in a zone.
Stop the VM.
Swap the OS disk of the VM.
Detach any data disks from the VM.
Attach data disks created from the snapshots in step 1.
Restart the VM.
Next steps
For more information, see Perform an in-place upgrade of Windows Server
Feedback
Submit and view feedback for