Azure disk

Vamsi krishna Machavarapu 1 Reputation point
2022-03-23T04:10:44.23+00:00

Does the data will be available once detaching the disk from the vm? Can I use same disk later in sometime with existing data?

Azure Disk Storage
Azure Disk Storage
A high-performance, durable block storage designed to be used with Azure Virtual Machines and Azure VMware Solution.
650 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Andriy Bilous 11,536 Reputation points MVP
    2022-03-23T05:06:15.897+00:00

    Hello @Vamsi krishna Machavarapu

    If you detach a disk it is not automatically deleted and all data will be preserved.
    You can attach an existing managed disk with your data to a new VM as a data disk.
    Using Powershell:

    $rgName = "myResourceGroup"  
    $vmName = "myVM"  
    $dataDiskName = "myDisk"  
    $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  
    

    Then Add data disk at OS level
    https://learn.microsoft.com/en-us/azure/virtual-machines/windows/attach-disk-ps

    Using Portal:

    1. Go to the Azure portal to find the VM. Search for and select Virtual machines.
    2. Choose the VM from the list.
    3. In the Virtual machines page, under Settings, choose Disks.
    4. On the Disks pane, under Data disks, select Attach existing disks.
    5. Click the drop-down menu for Disk name and select a disk from the list of available managed disks.
    6. Click Save to attach the existing managed disk and update the VM configuration
    7. Add data disk at OS level
      https://learn.microsoft.com/en-us/azure/virtual-machines/linux/attach-disk-portal
      https://learn.microsoft.com/en-us/azure/devtest-labs/devtest-lab-attach-detach-data-disk
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.