I am creating a VM in Azure through ARM Template using an existing image. The image already has a datadisk. I am trying to add additional data-disks through ARM Template while creating the VM. Can I do so ? I am getting below listed error:-

Can not add property dataDisks to Newtonsoft.Json.Linq.JObject. Property with the same name already exists on object
1

There are 1 answers

0
Charles Xu On BEST ANSWER

Well, if your image already has data disks, then when you create the VM through the ARM template, you need also configure the datadisk block for the existing data disk. Just set the createOption with the value fromImage. Then set the additional data disk as usual. For example, your image has one data disk, and you also need to attach another data disk, then the dataDisk block would like this:

"dataDisks": [
    {
        "lun": 0,
        "createOption": "fromImage",
        "caching": "ReadOnly",
        "writeAcceleratorEnabled": false,
        "id": null,
        "name": null,
        "storageAccountType": "Premium_LRS",
        "diskSizeGB": null,
        "diskEncryptionSet": null
    },
    {
        "lun": 1,
        "createOption": "attach",
        "caching": "None",
        "writeAcceleratorEnabled": false,
        "id": null,
        "name": "azurevm_DataDisk_1",
        "storageAccountType": null,
        "diskSizeGB": null,
        "diskEncryptionSet": null
    }
]

It's just an example, you can change the values as you need, the most important thing for you is the createOption. And the first is for the existing data disk, the same type, and other things also should be the same as it is in the image.