# Error to deploy an Azure image with datadisk

**URL:** <https://discuss.hashicorp.com/t/error-to-deploy-an-azure-image-with-datadisk/52251>\
**Category:** Azure\
**Created:** [April 3, 2023, 4:55pm UTC](https://discuss.hashicorp.com/t/error-to-deploy-an-azure-image-with-datadisk/52251 "2023-04-03T16:55:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sa\_soliveira](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/sa_soliveira/32/34905_2.png) [@sa\_soliveira](https://discuss.hashicorp.com/u/sa_soliveira)\
**Post date:** [April 3, 2023, 4:55pm UTC](https://discuss.hashicorp.com/t/error-to-deploy-an-azure-image-with-datadisk/52251/1 "2023-04-03T16:55:41Z")

</div>

Hello,

I have the same incident related in the following topic without a resolution:

> [@Can create virtual linux machine from custom image which has data disk](https://discuss.hashicorp.com/t/can-create-virtual-linux-machine-from-custom-image-which-has-data-disk/10457):
>
> 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 “sourc…

I have created an Azure Image which has an OS disk and a data disk attached. However, when I try to deploy that image via Terraform I got the following error:

│ Error: creating Linux Virtual Machine: (Name “myVM1298821” / Resource Group “non-prod”): 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”

Is there any limitation or workaround for this error? Any suggestion is appreciated.

This is my main.tf file related:

data “azurerm\_shared\_image” “MusaReviewImage” {  
name = “MusaReviewImage1”  
gallery\_name = “MusaReviewImage”  
resource\_group\_name = “non-prod”

}

# Create virtual machine

resource “azurerm\_linux\_virtual\_machine” “my\_terraform\_vm” {  
name = “myVM1298821”  
location = var.location  
resource\_group\_name = var.resourceGroupName  
network\_interface\_ids = [azurerm\_network\_interface.my\_terraform\_nic.id]  
size = “Standard\_D2s\_v3”  
admin\_username = “xxxx”  
admin\_password = “xxxx”  
disable\_password\_authentication = false

os\_disk {  
name = “myOsDisk”  
caching = “ReadWrite”  
storage\_account\_type = “Premium\_LRS”  
}

source\_image\_id = “/subscriptions/e376b54a-c9bb-46cc-82e6-bde36010da8a/resourceGroups/non-prod/providers/Microsoft.Compute/galleries/MusaReviewImage/images/MusaReviewImage1/versions/0.0.1”

boot\_diagnostics {  
storage\_account\_uri = azurerm\_storage\_account.my\_storage\_account.primary\_blob\_endpoint  
}  
}

resource “azurerm\_managed\_disk” “dataDisk” {  
name = “datadisk”  
location = var.location  
resource\_group\_name = var.resourceGroupName  
storage\_account\_type = “StandardSSD\_LRS”  
create\_option = “Empty”  
disk\_size\_gb = 250

}

```
  resource "azurerm_virtual_machine_data_disk_attachment" "attachDisk" {
  managed_disk_id = azurerm_managed_disk.dataDisk.id
  virtual_machine_id = azurerm_linux_virtual_machine.my_terraform_vm.id
  lun = "10"
  caching = "ReadWrite"
  depends_on = [
    azurerm_linux_virtual_machine.my_terraform_vm
  ]

```

}
