Hello @John Huynh ,
Welcome to Microsoft QnA.
Your choice to create a generation 1 or generation 2 virtual machine depends on which guest operating system and boot method you want to use to deploy the virtual machine. Generation 1 virtual machines support most guest operating systems. Generation 2 virtual machines support most 64-bit versions of Windows and more current versions of Linux and FreeBSD operating systems
You need to first verify if the OS you are choosing during VM creation supports your choice of VM generation (gen 2) by checking it from this document.
In the ARM template, you need to navigate to imageReference under properties, and there in the sku you will have to mention the sku name.
For example, Windows Server 2019 Datacenter image supports both gen 1 and gen 2, so here's how the difference in the sku would look like for each generation.
for gen 1:
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2019-Datacenter",
"version": "latest"
}
for gen 2:
"imageReference": {
"publisher": "canonical",
"offer": "0001-com-ubuntu-server-focal",
"sku": "20_04-lts-gen2",
"version": "latest"
}
Hope this helps.
You can also check the name of skus if you are unsure by downloading the template from Azure portal, and modifying it in your ARM template.
Check the below image for reference. You can choose to select Download a template for automation after selecting the VM image during creation and confirm the sku.
--------------------
If you find the above information helpful, kindly accept as answer or upvote to increase the relevancy of this post.