Getting error PropertyChangeNotAllowed while creating VM in Azure

RAVINDRA H (ravinh) 21 Reputation points
2021-10-11T07:56:44.48+00:00

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

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]
}

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” {

Please let me know how to resolve this issue.

Terraform and Azure provider version details are given below: Terraform v1.0.8 on linux_amd64

provider registry.terraform.io/hashicorp/azurerm v2.79.1

Thanks & Regards,
-Ravi

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,065 questions
Azure Disk Storage
Azure Disk Storage
A high-performance, durable block storage designed to be used with Azure Virtual Machines and Azure VMware Solution.
569 questions
{count} votes