1

Is there any Azure Resource Template documentation? I am trying to recreate a VM using Resource Template and the only thing I am missing is creating a data disk from image the same way the OS disk is created. I edited the JSON template:

          "dataDisks": [
        {
          "lun": 0,
          "name": "[concat(parameters('virtualMachines_testVM_name'),'-disk-1')]",
          "createOption": "FromImage",
          "vhd": {
            "uri": "[concat('https', '://', parameters('storageAccounts_rmtemplatetest6221copy_name'), '.blob.core.windows.net', concat('/vhds/', parameters('virtualMachines_testVM_name'),'-disk-1-201649102835.vhd'))]"
          },
          "caching": "ReadWrite"
        }
      ]

But I get following error in Azure when deploying the template

Required parameter 'dataDisk.image' is missing

So far the only way I got to recreate the data disk was to delete above code from the JSON template and then use Powershell after the machine is created without the data disk, but I would like to automate deployment with resource template only.

Tomasz Tuczapski
  • 319
  • 4
  • 17

2 Answers2

1

In the Azure quick start templates you can find JSON template for creating VM using custom images, including Data disks:

https://github.com/Azure/azure-quickstart-templates/tree/master/101-vm-user-image-data-disks

Just one very important note - the targed storage account should be same account where your VHDs reside.

There is no standing documentation on the JSON Schema. The best source is to check out the Schema itself, so:

UPDATE

When you create VM based on custom image, including data disks, you must create the entire VM in the same storage account where your custom data disks reside. There is no option, as of today (2016-05-10) to instruct ARM to copy VHDs across storage accounts.

This all was, if you want to create a VM from custom image with Data Disks. If you just want to create the VM with new, empty data disks, then you can use the following quick start template:

https://github.com/Azure/azure-quickstart-templates/tree/master/101-vm-multiple-data-disk

where you only define the desired size of the data disks and where they should be stored.

astaykov
  • 30,768
  • 3
  • 70
  • 86
  • I don't understand what "the targed storage account should be same account where your VHDs reside" means, are you saying that you can't create a vm and spread the disks across multiple storage accounts? I'm also not sure that this answers the question, it just points to the (closest thing there is) to documentation – Michael B May 10 '16 at 15:17
  • I was creating the VM in the same resource group as storage account containing both OS and data disks, so I think that all requirements were met. Error was indicating that I was missing some parameter so I don't think it was related to location of storage accounts. Also the 101-vm-multiple-data-disk quick start template is not working for me: https://github.com/Azure/azure-quickstart-templates/issues/1938 – Tomasz Tuczapski May 11 '16 at 07:13
0

The problem you are having is that you have the template configured to make a copy of an image, and you have no image specified.

You need to either set the createOption to fromImage, and specify an image

"dataDisks": [
 {
  "name": "[concat(variables('vmName'),'-dataDisk')]",
  "lun": 0,
  "createOption": "FromImage",            
  "image": {
    "uri": "[variables('dataDiskUrl')]"
    },
  "vhd": {
    "uri": "[variables('dataDiskVhdName')]"
    }
}
],

or, if you just want to use an existing disk, you can use attach, (you can also use empty in this configuration, and it will create an empty disk)

"dataDisks": [
{
    "name": "[concat(variables('vmName'),'-dataDisk')]",
    "lun": 0,
    "createOption": "attach",          
    "vhd": {
    "uri": "[variables('dataDiskVhdName')]"
   }
}
],
Michael B
  • 11,887
  • 6
  • 38
  • 74
  • This is exactly what I was missing and looking for, in my case there is no need to create another copy of an image, just attach the already existing image. – Tomasz Tuczapski May 11 '16 at 08:32