Error provisioning Windows VM from the Azure Gallery using azurerm windows virtual machine: Parameter 'osProfile' is not allowed

When using the azurerm_windows_virtual_machine, to provision a Windows VM from the Azure Compute Gallery (and a Specialised Image), I get an error:

Original Error: Code="InvalidParameter" Message="Parameter 'osProfile' is not allowed." Target="osProfile"

However, the osProfile parameter is NOT specified in the resource block. Indeed, it is not even a valid parameter for this resource type.

It is available in the now-deprecated azurerm_virtual_machine resource, but that is not what I am using.

Here is the resource block:

resource "azurerm_windows_virtual_machine" "windows" {
  admin_password              = "Password1234!"
  admin_username              = "testadmin"
  name                        = "testingvm"
  resource_group_name         = "${}"
  location                    = "${data.azurerm_resource_group.main.location}"

  size                        = "Standard_NV6ads_A10_v5"
  network_interface_ids       = []
  secure_boot_enabled   	  = true
  vtpm_enabled                = true

  source_image_id             = "/subscriptions/xxxxx-xxxx-xxxx/resourceGroups/Images/providers/Microsoft.Compute/galleries/MyAzureGallery/images/Windows2019_Specialised_gen1_StandrdSecurity"
  identity {
    type                      = "SystemAssigned"
  os_disk {
    name                      = "${var.prefix}-osdisk"
    caching                   = "ReadWrite"
    storage_account_type      = "Premium_LRS"
  depends_on = [

We are locked into TF v1.32, which I know is old, but I don’t have any control over that.

Could this be the issue? Or is there something I am missing?

Looks like this is a bug in Teraform - azurerm vm failed to create when provisioning a 'specialized' shared gallery image Issue (azurerm_linux_virtual_machine) · Issue #22968 · hashicorp/terraform-provider-azurerm · GitHub

This issue relate specifically to the azurerm_linux_virtual_machine resource, but I suspect it its the same for the azurerm_windows_virtual_machine resource as well.

Also see azurerm_windows_virtual_machine fails to create when referencing a "specialised" shared gallery image. · Issue #7772 · hashicorp/terraform-provider-azurerm · GitHub