Support for generation 2 VMs on Azure
Support for generation 2 virtual machines (VMs) is now available on Azure. You can't change a virtual machine's generation after you've created it, so review the considerations on this page before you choose a generation.
Generation 2 VMs support key features that aren't supported in generation 1 VMs. These features include increased memory, Intel Software Guard Extensions (Intel SGX), and virtualized persistent memory (vPMEM). Generation 2 VMs running on-premises, have some features that aren't supported in Azure yet. For more information, see the Features and capabilities section.
Generation 2 VMs use the new UEFI-based boot architecture rather than the BIOS-based architecture used by generation 1 VMs. Compared to generation 1 VMs, generation 2 VMs might have improved boot and installation times. For an overview of generation 2 VMs and some of the differences between generation 1 and generation 2, see Should I create a generation 1 or 2 virtual machine in Hyper-V?.
Generation 2 VM sizes
Generation 1 VMs are supported by all VM sizes in Azure (except for Mv2-series VMs). Azure now offers generation 2 support for the following selected VM series:
- DSv2-series and Dsv3-series
- Ls-series and Lsv2-series
- NCv2-series and NCv3-series
The usage of generation 2 VM images for Mv2-series VMs is generally available since the Mv2-series works with generation 2 VM images exclusively. Generation 1 VM images are not supported on Mv2-series VMs.
Generation 2 VM images in Azure Marketplace
Generation 2 VMs support the following Marketplace images:
- Windows Server 2019, 2016, 2012 R2, 2012
- Windows 10 Pro, Windows 10 Enterprise
- SUSE Linux Enterprise Server 15 SP1
- SUSE Linux Enterprise Server 12 SP4
- Ubuntu Server 16.04, 18.04, 19.04, 19.10
- RHEL 8.1, 8.0, 7.7, 7.6, 7.5, 7.4, 7.0
- Cent OS 8.0, 7.7, 7.6, 7.5, 7.4
- Oracle Linux 7.7, 7.7-CI
On-premises vs. Azure generation 2 VMs
Azure doesn't currently support some of the features that on-premises Hyper-V supports for generation 2 VMs.
|Generation 2 feature||On-premises Hyper-V||Azure|
|Virtualization-based security (VBS)||✔️||❌|
Features and capabilities
Generation 1 vs. generation 2 features
|Feature||Generation 1||Generation 2|
|VM sizes||All VM sizes||Only VMs that support premium storage|
Generation 1 vs. generation 2 capabilities
|Capability||Generation 1||Generation 2|
|OS disk > 2 TB||❌||✔️|
|Custom disk/image/swap OS||✔️||✔️|
|Virtual machine scale set support||✔️||✔️|
|Azure Site Recovery||✔️||✔️|
|Shared image gallery||✔️||✔️|
|Azure disk encryption||✔️||❌|
Creating a generation 2 VM
In the Azure portal or Azure CLI, you can create generation 2 VMs from a Marketplace image that supports UEFI boot.
Below are the steps to create a generation 2 (Gen2) VM in Azure portal.
- Sign in to the Azure portal at https://portal.azure.com.
- Select Create a resource.
- Click See all from the Azure Marketplace on the left.
- Select an image which supports Gen2.
- Click Create.
- In the Advanced tab, under the VM generation section, select the Gen 2 option.
- In the Basics tab, Under Instance details, go to Size and open the Select a VM size blade.
- Select a supported generation 2 VM.
- Go through the Azure portal creation flow to finish creating the VM.
You can also use PowerShell to create a VM by directly referencing the generation 1 or generation 2 SKU.
For example, use the following PowerShell cmdlet to get a list of the SKUs in the
Get-AzVMImageSku -Location westus2 -PublisherName MicrosoftWindowsServer -Offer WindowsServer
Alternatively, you can use the Azure CLI to see any available generation 2 images, listed by Publisher.
az vm image list --publisher Canonical --sku gen2 --output table --all
If you're creating a VM with Windows Server 2012 as the OS, then you will select either the generation 1 (BIOS) or generation 2 (UEFI) VM SKU, which looks like this:
See the Features and capabilities section for a current list of supported Marketplace images.
Managed image or managed disk
You can create a generation 2 VM from a managed image or managed disk in the same way you would create a generation 1 VM.
Virtual machine scale sets
You can also create generation 2 VMs by using virtual machine scale sets. In the Azure CLI, use Azure scale sets to create generation 2 VMs.
Frequently asked questions
Are generation 2 VMs available in all Azure regions?
Yes. But not all generation 2 VM sizes are available in every region. The availability of the generation 2 VM depends on the availability of the VM size.
Is there a price difference between generation 1 and generation 2 VMs?
I have a .vhd file from my on-premises generation 2 VM. Can I use that .vhd file to create a generation 2 VM in Azure? Yes, you can bring your generation 2 .vhd file to Azure and use that to create a generation 2 VM. Use the following steps to do so:
Upload the .vhd to a storage account in the same region where you'd like to create your VM.
Create a managed disk from the .vhd file. Set the Hyper-V Generation property to V2. The following PowerShell commands set Hyper-V Generation property when creating managed disk.
$sourceUri = 'https://xyzstorage.blob.core.windows.net/vhd/abcd.vhd'. #<Provide location to your uploaded .vhd file> $osDiskName = 'gen2Diskfrmgenvhd' #<Provide a name for your disk> $diskconfig = New-AzDiskConfig -Location '<location>' -DiskSizeGB 127 -AccountType Standard_LRS -OsType Windows -HyperVGeneration "V2" -SourceUri $sourceUri -CreateOption 'Import' New-AzDisk -DiskName $osDiskName -ResourceGroupName '<Your Resource Group>' -Disk $diskconfig
Once the disk is available, create a VM by attaching this disk. The VM created will be a generation 2 VM. When the generation 2 VM is created, you can optionally generalize the image of this VM. By generalizing the image, you can use it to create multiple VMs.
How do I increase the OS disk size?
OS disks larger than 2 TB are new to generation 2 VMs. By default, OS disks are smaller than 2 TB for generation 2 VMs. You can increase the disk size up to a recommended maximum of 4 TB. Use the Azure CLI or the Azure portal to increase the OS disk size. For information about how to expand disks programmatically, see Resize a disk.
To increase the OS disk size from the Azure portal:
- In the Azure portal, go to the VM properties page.
- To shut down and deallocate the VM, select the Stop button.
- In the Disks section, select the OS disk you want to increase.
- In the Disks section, select Configuration, and update the Size to the value you want.
- Go back to the VM properties page and Start the VM.
You might see a warning for OS disks larger than 2 TB. The warning doesn't apply to generation 2 VMs. However, OS disk sizes larger than 4 TB are not recommended.
Do generation 2 VMs support accelerated networking?
Yes. For more information, see Create a VM with accelerated networking.
Is VHDX supported on generation 2?
No, generation 2 VMs support only VHD.
Do generation 2 VMs support Azure Ultra Disk Storage?
Can I migrate a VM from generation 1 to generation 2?
No, you can't change the generation of a VM after you create it. If you need to switch between VM generations, create a new VM of a different generation.
Why is my VM size not enabled in the size selector when I try to create a Gen2 VM?
This may be solved by doing the following:
- Verify that the VM generation property is set to Gen 2 in the Advanced tab.
- Verify you are searching for a VM size which supports Gen2 VMs.