Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Azure by (13.1k points)
I have a VM, inside this VM I want to attached a Managed disk, and I am using ARM template to create a managed disk, But I am not sure how to attach this managed disk to a VM. Can anyone help me with this? How can I able to do it?

1 Answer

0 votes
by (26.7k points)

To add a managed disk to a VM, you can use the property called dataDisks under the storageProfile object of that VM resource. You can prefer the below example to understand it better.

[

    {

      "lun": 0,

      "name": "[concat(parameters('virtualMachineName'), '-datadisk1')]",

      "createOption": "attach",

      "managedDisk": {

        "id": "[resourceId('Microsoft.Compute/disks/', concat(parameters('virtualdisk1name')]"

      }

    },

    {

      "lun": 1,

      "name": "[concat(parameters('virtualMachineName'), '-datadisk2')]",

      "createOption": "attach",

      "managedDisk": {

        "id": "[resourceId('Microsoft.Compute/disks/', '-datadisk2'))]"

      }

    },

    {

      "lun": 2,

      "name": "[concat(parameters('virtualMachineName'), '-datadisk3')]",

      "createOption": "attach",

      "managedDisk": {

        "id": "[resourceId('Microsoft.Compute/disks/' ,'-datadisk3'))]"

      }

    }

]

I hope this will work.

Want to become  an Azure Expert? join Azure Training now!!

Related questions

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...