简体   繁体   中英

How to attach new data disks to an existing Azure Virtual Machine using ARM template

I would like to know how to attach new data disks to an existing Azure VM using an ARM template.

I do not want to create a new VM and this is what the current documentation shows. If omit information like the hardwareProfile and networkProfile, the template is not considered valid.

A satisfactory answer shows the json template for attaching two new data disks to an existing VM without having to provide auxillary information about the vm.

As per my knowledge, you can't attach a data disk to a VM through an ARM template, however you can accomplish that through PowerShell ARM Cmdlet as below

$VirtualMachine = Get-AzureRmVM -ResourceGroupName "ResourceGroup11" -Name "VirtualMachine07"
Add-AzureRmVMDataDisk -VM $VirtualMachine -Name "disk1" -VhdUri "URL to VHD file" -LUN 0 -Caching ReadOnly -DiskSizeinGB 1 -CreateOption Empty
Update-AzureRmVM -ResourceGroupName "ResourceGroup11" -Name "VirtualMachine07" -VM $VirtualMachine

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM