Can create virtual linux machine from custom image which has data disk

I created a custom image which has one OS disk and one data disk.

resource “azurerm_image” “saplinux” {
name = “TEST”
location = “eastus”
resource_group_name = “rg-eus-prod-001”

os_disk {
  os_type  = "Linux"
  os_state = "Generalized"
  caching  = "ReadWrite"
  blob_uri = "https://xxxx/vhds/A0DFOF44RHE076-1.vhd"
  size_gb  = 27
}

data_disk {
  blob_uri = "https://xxx/vhds/A0DFOF44RHE076-2.vhd"
  caching  = "ReadWrite"
  size_gb  = 23
  lun = 0
}

}

I use “source_image_id” to refer to this image

source_image_id = azurerm_image.saplinux.id

But when I ran “terraform apply”, I got this error:

Error: Error creating Linux Virtual Machine “vma0dfeustest001” (Resource Group “rg-a0df-eus-prod-001”): compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=400 – Original Error: Code=“InvalidParameter” Message=“StorageProfile.dataDisks.lun does not have required value(s) for image specified in storage profile.” Target=“storageProfile”

Custom image is created successfully, any idea about this error?

1 Like

hey xuhaiwei , were you able to get a fix for this, I seems to have the same issue when using a managed image w/ data disk attached to it.

I am facing the similar issue Error: Code=“InvalidParameter” Message=“StorageProfile.dataDisks.lun does not have required value(s) for image specified in storage profile.” Target=“storageProfile”
I am using a custom image DDVE and it has one data disk predefined which causing this issue. Below is the image details that Iam using in my VM configuration
image_publisher = “dellemc”,
image_offer = “dell-emc-datadomain-virtual-edition-v4”,
image_sku = “ddve-40-ver-7105”,
image_version = “latest”,

Can anybody help me how to fix this issue.

Hey soibam , were you able to fix it ?