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

**URL:** <https://discuss.hashicorp.com/t/can-create-virtual-linux-machine-from-custom-image-which-has-data-disk/10457>\
**Category:** Azure\
**Created:** [June 24, 2020, 2:22am UTC](https://discuss.hashicorp.com/t/can-create-virtual-linux-machine-from-custom-image-which-has-data-disk/10457 "2020-06-24T02:22:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![xuhaiwei](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/xuhaiwei/32/8453_2.png) [@xuhaiwei](https://discuss.hashicorp.com/u/xuhaiwei)\
**Post date:** [June 24, 2020, 2:22am UTC](https://discuss.hashicorp.com/t/can-create-virtual-linux-machine-from-custom-image-which-has-data-disk/10457/1 "2020-06-24T02:22:26Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![shashank0033-stack](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/shashank0033-stack/32/9071_2.png) [@shashank0033-stack](https://discuss.hashicorp.com/u/shashank0033-stack)\
**Post date:** [July 7, 2020, 6:55am UTC](https://discuss.hashicorp.com/t/can-create-virtual-linux-machine-from-custom-image-which-has-data-disk/10457/2 "2020-07-07T06:55:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![soibam.indrakumar](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/soibam.indrakumar/32/26600_2.png) [@soibam.indrakumar](https://discuss.hashicorp.com/u/soibam.indrakumar)\
**Post date:** [March 10, 2022, 12:57pm UTC](https://discuss.hashicorp.com/t/can-create-virtual-linux-machine-from-custom-image-which-has-data-disk/10457/3 "2022-03-10T12:57:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![iroshifs](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/iroshifs/32/43280_2.png) [@iroshifs](https://discuss.hashicorp.com/u/iroshifs)\
**Post date:** [August 19, 2023, 6:59am UTC](https://discuss.hashicorp.com/t/can-create-virtual-linux-machine-from-custom-image-which-has-data-disk/10457/4 "2023-08-19T06:59:03Z")

</div>

Hey soibam , were you able to fix it ?

---

<div class="post-metadata">

**Author:** ![jan-isacsson](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/jan-isacsson/32/18885_2.png) [@jan-isacsson](https://discuss.hashicorp.com/u/jan-isacsson)\
**Post date:** [April 25, 2024, 2:39pm UTC](https://discuss.hashicorp.com/t/can-create-virtual-linux-machine-from-custom-image-which-has-data-disk/10457/5 "2024-04-25T14:39:48Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ExtelligenceIT](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/extelligenceit/32/41411_2.png) [@ExtelligenceIT](https://discuss.hashicorp.com/u/ExtelligenceIT)\
**Post date:** [April 25, 2024, 5:32pm UTC](https://discuss.hashicorp.com/t/can-create-virtual-linux-machine-from-custom-image-which-has-data-disk/10457/6 "2024-04-25T17:32:12Z")

</div>

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)](https://github.com/hashicorp/terraform-provider-azurerm/issues/6117)

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.  
> …

---

<div class="post-metadata">

**Author:** ![iroshifs](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/iroshifs/32/43280_2.png) [@iroshifs](https://discuss.hashicorp.com/u/iroshifs)\
**Post date:** [April 29, 2024, 4:13am UTC](https://discuss.hashicorp.com/t/can-create-virtual-linux-machine-from-custom-image-which-has-data-disk/10457/7 "2024-04-29T04:13:12Z")

</div>

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 .
