{"action":"opened","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/10449","repository_url":"https://api.github.com/repos/hashicorp/terraform","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/10449/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/10449/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/10449/events","html_url":"https://github.com/hashicorp/terraform/issues/10449","id":192689012,"number":10449,"title":"azurerm_virtual_machine Not Attaching Data Disks - \"InvalidVhd\"","user":{"login":"TStraub-rms","id":19933791,"avatar_url":"https://avatars.githubusercontent.com/u/19933791?v=3","gravatar_id":"","url":"https://api.github.com/users/TStraub-rms","html_url":"https://github.com/TStraub-rms","followers_url":"https://api.github.com/users/TStraub-rms/followers","following_url":"https://api.github.com/users/TStraub-rms/following{/other_user}","gists_url":"https://api.github.com/users/TStraub-rms/gists{/gist_id}","starred_url":"https://api.github.com/users/TStraub-rms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TStraub-rms/subscriptions","organizations_url":"https://api.github.com/users/TStraub-rms/orgs","repos_url":"https://api.github.com/users/TStraub-rms/repos","events_url":"https://api.github.com/users/TStraub-rms/events{/privacy}","received_events_url":"https://api.github.com/users/TStraub-rms/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-11-30T21:46:39Z","updated_at":"2016-11-30T21:46:39Z","closed_at":null,"body":"### Terraform Version\r\n\r\nterraform version `0.7.10`\r\n\r\n### Affected Resource(s)\r\n\r\n- azurerm_virtual_machine\r\n- azurerm_storage_blob\r\n\r\n### Terraform Configuration Files\r\n\r\n```\r\nvariable \"tenant_id\" {}\r\nvariable \"client_id\" {}\r\nvariable \"client_secret\" {}\r\nvariable \"subscription_id\" {}\r\nvariable \"location\" {}\r\nvariable \"module_name\" {}\r\nvariable \"vnet_address_space\" {}\r\nvariable \"subnet1\" {}\r\nvariable \"admin_username\" {}\r\nvariable \"admin_password\" {}\r\nvariable \"instance_type\" {\r\n  default = \"standard_a1\"\r\n}\r\nvariable \"instance_count\" {\r\n  default = 1\r\n}\r\nvariable \"data_disk_size_gb\" {\r\n  default = 1\r\n}\r\n\r\nprovider \"azurerm\" {\r\n  tenant_id       = \"${var.tenant_id}\"\r\n  subscription_id = \"${var.subscription_id}\"\r\n  client_id       = \"${var.client_id}\"\r\n  client_secret   = \"${var.client_secret}\"\r\n}\r\n\r\nresource \"azurerm_resource_group\" \"module\" {\r\n  name     = \"${var.module_name}\"\r\n  location = \"${var.location}\"\r\n}\r\n\r\nresource \"azurerm_virtual_network\" \"module\" {\r\n  name                = \"${var.module_name}-Vnet1\"\r\n  resource_group_name = \"${azurerm_resource_group.module.name}\"\r\n  address_space       = [\"${var.vnet_address_space}\"]\r\n  location            = \"${var.location}\"\r\n}\r\n\r\nresource \"azurerm_subnet\" \"subnet1\" {\r\n  name                 = \"${var.module_name}-SubNet1\"\r\n  resource_group_name  = \"${azurerm_resource_group.module.name}\"\r\n  virtual_network_name = \"${azurerm_virtual_network.module.name}\"\r\n  address_prefix       = \"${var.subnet1}\"\r\n}\r\n\r\nresource \"azurerm_network_interface\" \"module\" {\r\n  count               = \"${var.instance_count}\"\r\n  name                = \"${azurerm_resource_group.module.name}${count.index + 1}\"\r\n  resource_group_name = \"${azurerm_resource_group.module.name}\"\r\n  location            = \"${var.location}\"\r\n\r\n  ip_configuration {\r\n    name                          = \"${azurerm_resource_group.module.name}${count.index + 1}\"\r\n    subnet_id                     = \"${azurerm_subnet.subnet1.id}\"\r\n    private_ip_address_allocation = \"dynamic\"\r\n  }\r\n}\r\n\r\nresource \"azurerm_storage_container\" \"module\" {\r\n  name                  = \"vhds\"\r\n  resource_group_name   = \"${azurerm_resource_group.module.name}\"\r\n  storage_account_name  = \"${azurerm_storage_account.module.name}\"\r\n  container_access_type = \"private\"\r\n}\r\n\r\nresource \"azurerm_storage_account\" \"module\" {\r\n  name                = \"${azurerm_resource_group.module.name}random1\"\r\n  resource_group_name = \"${azurerm_resource_group.module.name}\"\r\n  location            = \"${var.location}\"\r\n  account_type        = \"Standard_LRS\"\r\n}\r\n\r\nresource \"azurerm_storage_blob\" \"module\" {\r\n  name                   = \"${azurerm_resource_group.module.name}${count.index + 1}data.vhd\"\r\n  count                  = \"${var.instance_count}\"\r\n  resource_group_name    = \"${azurerm_resource_group.module.name}\"\r\n  storage_account_name   = \"${azurerm_storage_account.module.name}\"\r\n  storage_container_name = \"${azurerm_storage_container.module.name}\"\r\n  type                   = \"page\"\r\n  size                   = \"${var.data_disk_size_gb * 1073741824 + 512}\"\r\n}\r\n\r\nresource \"azurerm_virtual_machine\" \"module\" {\r\n  name                  = \"${azurerm_resource_group.module.name}${count.index + 1}\"\r\n  count                 = \"${var.instance_count}\"\r\n  location              = \"${var.location}\"\r\n  resource_group_name   = \"${azurerm_resource_group.module.name}\"\r\n  network_interface_ids = [\"${element(azurerm_network_interface.module.*.id, count.index)}\"]\r\n  vm_size               = \"${var.instance_type}\"\r\n\r\n  storage_image_reference {\r\n    publisher = \"OpenLogic\"\r\n    offer     = \"CentOS\"\r\n    sku       = \"7.2\"\r\n    version   = \"latest\"\r\n  }\r\n\r\n  storage_os_disk {\r\n    name          = \"${azurerm_resource_group.module.name}${count.index + 1}os\"\r\n    vhd_uri       = \"${azurerm_storage_account.module.primary_blob_endpoint}${azurerm_storage_container.module.name}/${azurerm_resource_group.module.name}${count.index + 1}os.vhd\"\r\n    caching       = \"ReadWrite\"\r\n    create_option = \"FromImage\"\r\n  }\r\n\r\n  storage_data_disk {\r\n    name          = \"${azurerm_resource_group.module.name}${count.index + 1}data\"\r\n    vhd_uri       = \"${azurerm_storage_account.module.primary_blob_endpoint}${azurerm_storage_container.module.name}/${element(azurerm_storage_blob.module.*.name, count.index)}\"\r\n    create_option = \"Attach\"\r\n    disk_size_gb  = \"${var.data_disk_size_gb}\"\r\n    lun           = \"0\"\r\n  }\r\n\r\n  os_profile {\r\n    computer_name  = \"${azurerm_resource_group.module.name}${count.index + 1}\"\r\n    admin_username = \"${var.admin_username}\"\r\n    admin_password = \"${var.admin_password}\"\r\n  }\r\n}\r\n```\r\n\r\n### Expected Behavior\r\nThe Virtual Machine should be created with an empty data disk attached.\r\n\r\n### Actual Behavior\r\n\r\n`terraform apply` will create all the resources without an issue except for the Virtual Machine.\r\nWhen creating the VM and attaching the data disk there is an error:\r\n\r\n```\r\nError applying plan:\r\n\r\n1 error(s) occurred:\r\n\r\n* azurerm_virtual_machine.module: compute.VirtualMachinesClient#CreateOrUpdate: Failure \r\nsending request: StatusCode=200 -- Original Error: Long running operation terminated with status \r\n'Failed': Code=\"InvalidVhd\" Message=\"The specified cookie value in VHD footer indicates that disk \r\n'testdata1data' with blob https://<OMITTED>.blob.core.windows.net/vhds/testdata1data.vhd is not a \r\nsupported VHD. Disk is expected to have cookie value 'conectix'.\"\r\n```\r\n\r\n### Steps to Reproduce\r\n\r\n1. `terraform apply`\r\n\r\n### Important Factoids\r\n\r\nThis had been working for us in the past without issue and is currently being used in several environments.\r\nThe error started occuring in the last few weeks with existing terraform code that has worked for a few months without modifications. I have compiled a small example above to demonstrate the problem.\r\nI have tried several older version of Terraform back to (0.7.4) which lead me to believe this is a change in the Azure API or Terraforms interaction with the API. \r\n\r\nIt appears that this code is no longer creating a valid empty vhd that can be attached as a data disk to an Azure Virtual Machine:\r\n\r\n```\r\nresource \"azurerm_storage_blob\" \"module\" {\r\n  name                   = \"${azurerm_resource_group.module.name}${count.index + 1}data.vhd\"\r\n  count                  = \"${var.instance_count}\"\r\n  resource_group_name    = \"${azurerm_resource_group.module.name}\"\r\n  storage_account_name   = \"${azurerm_storage_account.module.name}\"\r\n  storage_container_name = \"${azurerm_storage_container.module.name}\"\r\n  type                   = \"page\"\r\n  size                   = \"${var.data_disk_size_gb * 1073741824 + 512}\"\r\n}\r\n```\r\n"}}
{"actor":{"display_login":"TStraub-rms"}}