Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to specify a custom VHD to azurerm_virtual_machine resource? #1042

Closed
seanknox opened this issue Mar 29, 2018 · 4 comments
Closed

How to specify a custom VHD to azurerm_virtual_machine resource? #1042

seanknox opened this issue Mar 29, 2018 · 4 comments

Comments

@seanknox
Copy link
Contributor

I've built a custom Ubuntu VHD on blob storage using Packer and I'm trying to boot a VM using it but am getting this error:

 * azurerm_virtual_machine.bastion: compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="InvalidParameter" Message="Cannot specify user image overrides for a disk already defined in the specified image reference."

Terraform Version

Terraform v0.11.5

Affected Resource(s)

Please list the resources as a list, for example:

  • azurerm_virtual_machine
    .

Terraform Configuration Files

resource "azurerm_virtual_machine" "bastion" {
  name                  = "bastion"
  location              = "${ var.location }"
  resource_group_name   = "${ var.name }"
  network_interface_ids = ["${azurerm_network_interface.bastion.id}"]
  vm_size               = "Standard_DS1_v2"

  # Uncomment this line to delete the OS disk automatically when deleting the VM
  delete_os_disk_on_termination = true

  # Uncomment this line to delete the data disks automatically when deleting the VM
  delete_data_disks_on_termination = true

  storage_os_disk {
    name          = "bastionosdisk"
    vhd_uri       = "https://acstackimages.blob.core.windows.net/system/Microsoft.Compute/Images/acs-vhds/acstack-1522124889-osDisk.8d0e099c-0ed0-483e-9d53-053057eb13b0.vhd"
    caching       = "ReadWrite"
    create_option = "FromImage"
  }
  os_profile {
    computer_name  = "bastion"
    admin_username = "ubuntu"
    admin_password = "Kangaroo-jeremiah-thereon1!"
  }
  os_profile_linux_config {
    disable_password_authentication = true

    ssh_keys = [{
      path     = "/home/ubuntu/.ssh/authorized_keys"
      key_data = "${ data.template_file.ssh-pub-key.rendered }"
    }]
  }
  boot_diagnostics {
    enabled     = "true"
    storage_uri = "${ var.storage_endpoint }"
  }
  connection {
    host        = "${azurerm_public_ip.bastion.ip_address}"
    user        = "ubuntu"
    type        = "ssh"
    private_key = "${ data.template_file.ssh-private-key.rendered }"
    timeout     = "2m"
    agent       = true
  }
  provisioner "remote-exec" {
    inline = [
      "sudo docker run -d -p 8080:80 nginx",
    ]
  }
  tags {
    environment = "staging"
  }
}

Expected Behavior

Created an VM from an VHD on blob storage

Actual Behavior

 * azurerm_virtual_machine.bastion: compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="InvalidParameter" Message="Cannot specify user image overrides for a disk already defined in the specified image reference."

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply
@metacpp
Copy link
Contributor

metacpp commented Mar 29, 2018

@seanknox if you want to create a VM from custom image, we will do through below steps:

#1, please follow below URL to create an image resource from custom VHD,
https://www.terraform.io/docs/providers/azurerm/r/image.html#example-usage-creating-from-vhd

#2, please follow below URL to create VM with managed disk from above custom image data:
https://www.terraform.io/docs/providers/azurerm/r/virtual_machine.html#example-usage-with-managed-disks-and-custom-images-recommended-

@seanknox
Copy link
Contributor Author

#1 worked great. Thanks Su!

@ghost
Copy link

ghost commented Mar 25, 2020

can somebody help on creating Azure VM from image of shared image gallery

@ghost
Copy link

ghost commented Mar 25, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants