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




  1. Create 2 virtual machines with the name "MYVM" and "MYVM1"
  2. Picture showing 2 virtual machines in Azure

    Click to Enlarge

  3. Inside the virtual machine "MYVM", create a data disk
  4. Picture showing the data disk in the virtual machine

    Click to Enlarge

  5. Login to the virtual machine using RDP
  6. Inside the data disk, create a notepad file and write some text in it
  7. Picture showing the notepad file created inside the virtual machine

    Click to Enlarge

  8. Go to the Azure portal. Click on the disk and inside it, click on the "Create snapshot"
  9. Picture showing the Create snapshot button for creating the snapshot

    Click to Enlarge

  10. In the create screenshot screen, select the "Resource Group" and enter the "Name"
  11. Picture showing the screen for creating the snapshot

    Click to Enlarge

  12. Finally, click on the "Review + Create" button for data validation. Once the data validation is done, click on the "Create" button
  13. Once the snapshot is created, go into the details of the snapshot. Inside the snapshot, click on the "Create Disk"
  14. Picture showing the Create Disk button for creating the disk for the snapshot

    Click to Enlarge

  15. A screen will come to enter the disk details. Select the "Resource Group" and enter the "Disk name"
  16. Picture showing the detail screen for creating the disk

    Click to Enlarge

  17. Finally, click on the "Review + Create" button and then click on the "Create" button
  18. Open PowerShell and write the following command to attach the existing disk to the virtual machine "MYVM1"
  19. $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


  20. Once the above commands are executed, the data disk is attached to the virtual machine "MYVM1"
  21. Picture showing the data disk attached to the another virtual machine

    Click to Enlarge

  22. Now, login to the "MYVM1" and check the data disk for the notepad file that we have created in the other virtual machine
  23. Picture showing the text file created in the another virtual machine

    Click to Enlarge



Posted By  -  Karan Gupta
 
Posted On  -  Tuesday, April 20, 2021

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250