I agree - that the documentation is poor. You could raise an issue against the azurerm provider to have the documentation improved for this. But the MS documentation for this resource in ARM is not much more verbose: ( Microsoft.DesktopVirtualization/hostPools - Bicep, ARM template & Terraform AzAPI reference | Microsoft Learn
The vm_template
attribute is for sessionhosts configuration within hostpool.
Here is an example taken from a template of an existing host pool via the export template feature of the Azure portal:
"vmTemplate": "{\"domain\":\"\",\"galleryImageOffer\":\"windows-11\",\"galleryImagePublisher\":\"microsoftwindowsdesktop\",\"galleryImageSKU\":\"win11-22h2-avd\",\"imageType\":\"Gallery\",\"customImageId\":null,\"namePrefix\":\"avdtesthost\",\"osDiskType\":\"StandardSSD_LRS\",\"vmSize\":{\"id\":\"Standard_D2as_v5\",\"cores\":2,\"ram\":8},\"galleryItemId\":\"microsoftwindowsdesktop.windows-11win11-22h2-avd\",\"hibernate\":false,\"diskSizeGB\":128,\"securityType\":\"TrustedLaunch\",\"secureBoot\":true,\"vTPM\":true,\"vmInfrastructureType\":\"Cloud\",\"virtualProcessorCount\":null,\"memoryGB\":null,\"maximumMemoryGB\":null,\"minimumMemoryGB\":null,\"dynamicMemoryConfig\":false}"
Which, when you remove all of the ‘escaping’ needed for an ARM template becomes:
"vmTemplate": {
"domain": "",
"galleryImageOffer": "windows-11",
"galleryImagePublisher": "microsoftwindowsdesktop",
"galleryImageSKU": "win11-22h2-avd",
"imageType": "Gallery",
"customImageId": null,
"namePrefix": "avdtesthost",
"osDiskType": "StandardSSD_LRS",
"vmSize": { "id": "Standard_D2as_v5", "cores": 2, "ram": 8 },
"galleryItemId": "microsoftwindowsdesktop.windows-11win11-22h2-avd",
"hibernate": false,
"diskSizeGB": 128,
"securityType": "TrustedLaunch",
"secureBoot": true,
"vTPM": true,
"vmInfrastructureType": "Cloud",
"virtualProcessorCount": null,
"memoryGB": null,
"maximumMemoryGB": null,
"minimumMemoryGB": null,
"dynamicMemoryConfig": false
}
I can’t find anywhere that documents this, even when referring to Add session hosts to a host pool - Azure Virtual Desktop | Microsoft Learn.
My approach would be, if unsure, temporarily add a host-pool via the portal with the configuration you desire and inspect the ARM template that is available via the ‘export template’ option to extract the JSON required for the vm_template
attribute.
You can then place the JSON into your module directly in the resource, or into a local variable using heredoc-strings or read from a local file, or pass in via in input variable.
Hope that helps
Happy Terraforming