Getting error PropertyChangeNotAllowed while creating VM in Azure

Hi All,

I’m trying to create a VM in Azure using below config.

Blockquote

resource “azurerm_virtual_machine” “VM38” {
name = “VM38”
resource_group_name = data.azurerm_resource_group.myRG.name
location = data.azurerm_resource_group.myRG.location
vm_size = “Standard_F16s_v2”
delete_os_disk_on_termination = true
delete_data_disks_on_termination = true

os_profile {
computer_name = “vm38”
admin_username = “adminuser”
admin_password = “Password1234!”
custom_data = base64encode(data.cloudinit_config.hybrid_vm38_cloudinit_cfg.rendered)
}

os_profile_linux_config {
disable_password_authentication = false
}

storage_image_reference {
id = data.azurerm_image.my_image.id
}

depends_on = [aws_instance.vm12]

storage_os_disk {
name = “VMDisk”
create_option = “FromImage”
caching = “ReadWrite”
#disk_size_gb = 16
#os_type = “Linux”
#managed_disk_type = “Standard_LRS”
vhd_uri = var.vmVHDURI
}

network_interface_ids = [
azurerm_network_interface.mgmtNwIntf.id,
azurerm_network_interface.transportNwIntf.id
]
}

Blockquote

When I execute terraform apply I’m getting below error…

Error: compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=0 – Original Error: autorest/azure: Service returned an error. Status= Code=“PropertyChangeNotAllowed” Message=“Changing property ‘osDisk.name’ is not allowed.” Target=“osDisk.name”

│ with azurerm_virtual_machine.VM38,
│ on az_virtual_machine.tf line 1, in resource “azurerm_virtual_machine” “VM38”:
│ 1: resource “azurerm_virtual_machine” “VM38” {

Terraform and Azure provider version details are given below:

Terraform v1.0.8
on linux_amd64

Please let me know how to resolve this issue.

Thanks & Regards,
-Ravi