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 ?
2024-04-25. I am getting the same error
Message=“StorageProfile.dataDisks.lun does not have required value(s) for image specified in storage profile.” Target=“storageProfile”
This seems to be a serious issue. We have plenty of VMs that needs to be created from images having data disks. How come nobody looking into this?
For those who may come across this post with the same issue it seems that there is an open issue for this on the provider
Support for disk attachment to VMs at creation time · Issue #6117 · hashicorp/terraform-provider-azurerm (github.com)
With the last update (As of 2024-04-25) being:
Execrpt:
…
unfortunately this issue is still blocked due to a combination of the behaviour of the Azure API (specifically the CreateOption
field) and limitations of the Terraform Plugin SDK.
…
Hello jan
When terraform check the require lun disk value from source image , he can’t find that disk number and that is why this error is giving .
Message=“StorageProfile.dataDisks.lun does not have required value(s) for image specified in storage profile.” Target=“storageProfile”
If you are use the azure compute gallery or what ever image galley to store the image , then you can pre-visualized the image storage profile as json format and please check whether data disk is already there or not which you are referred on terraform code
ex :
“osDiskImage”: {
“sizeInGB”: 32,
“hostCaching”: “ReadWrite”,
“source”: {}
},
“dataDiskImages”: [
{
“lun”: 1,
“sizeInGB”: 64,
“hostCaching”: “ReadWrite”
}
]
As a example , assume lun 1 data disk is not in this image and but we are try to refer this disk through the terraform and then above error may be given . I was sorted this issue like that and please try it .