Generation 2 azure VM


I can’t seem to create a generation 2 VM in Azure using Terraform. Neither resources
have an argument for generation listed in the standard docs on the terraform site.

When specifying a gen2 instance type, I get the following error:

Error: Error creating Linux Virtual Machine “nickgen2test-0” (Resource Group “nickgen2test-resources”): compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=400 – Original Error: Code=“BadRequest” Message=“The selected VM Size ‘Standard_DC4s_v2’ cannot boot Hypervisor Generation ‘1’. If this was a Create operation please check that the Hypervisor Generation of the Image matches the Hypervisor Generation of the selected VM Size. If this was an Update operation please select a Hypervisor Generation ‘1’ VM Size.”

Haven’t found anything when searching around online for creating gen2 vms. Is this supported?

For anyone who may comes across this in the future, the sku was my issue.

This article:
mentions a command
Get-AzVMImageSku -Location westus2 -PublisherName MicrosoftWindowsServer -Offer WindowsServer
Which lists the gen2 sku types.

sku = “16.04-LTS”
Just needs to be
sku = “16_04-lts-gen2”
And then any gen2 instance type will work.