Articles → MICROSOFT AZURE → Create A Snapshot Of The Data Disk From One Virtual Machine To Another In Azure
Create A Snapshot Of The Data Disk From One Virtual Machine To Another In Azure
What Is The Snapshot?
Implementation
- Create 2 virtual machines with the name "MYVM" and "MYVM1"
Click to Enlarge
- Inside the virtual machine "MYVM", create a data disk
Click to Enlarge
- Login to the virtual machine using RDP
- Inside the data disk, create a notepad file and write some text in it
Click to Enlarge
- Go to the Azure portal. Click on the disk and inside it, click on the "Create snapshot"
Click to Enlarge
- In the create screenshot screen, select the "Resource Group" and enter the "Name"
Click to Enlarge
- Finally, click on the "Review + Create" button for data validation. Once the data validation is done, click on the "Create" button
- Once the snapshot is created, go into the details of the snapshot. Inside the snapshot, click on the "Create Disk"
Click to Enlarge
- A screen will come to enter the disk details. Select the "Resource Group" and enter the "Disk name"
Click to Enlarge
- Finally, click on the "Review + Create" button and then click on the "Create" button
- Open PowerShell and write the following command to attach the existing disk to the virtual machine "MYVM1"
$rgName = 'RG'
$vmName = 'MYVM1'
$location = "East US"
$dataDiskName = "backupdisk"
$disk = Get-AzDisk -ResourceGroupName $rgName -DiskName $dataDiskName
$vm = Get-AzVM -Name $vmName -ResourceGroupName $rgName
$vm = Add-AzVMDataDisk -CreateOption Attach -Lun 0 -VM $vm -ManagedDiskId $disk.Id
Update-AzVM -VM $vm -ResourceGroupName $rgName
- Once the above commands are executed, the data disk is attached to the virtual machine "MYVM1"
Click to Enlarge
- Now, login to the "MYVM1" and check the data disk for the notepad file that we have created in the other virtual machine
Click to Enlarge