How to detach a data disk from a Windows virtual machine

When you no longer need a data disk that's attached to a virtual machine, you can easily detach it. This removes the disk from the virtual machine, but doesn't remove it from storage.


If you detach a disk it is not automatically deleted. If you have subscribed to Premium storage, you will continue to incur storage charges for the disk. For more information, see Pricing and Billing when using Premium Storage.

If you want to use the existing data on the disk again, you can reattach it to the same virtual machine, or another one.


This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. For Az module installation instructions, see Install Azure PowerShell.

Detach a data disk using PowerShell

You can hot remove a data disk using PowerShell, but make sure nothing is actively using the disk before detaching it from the VM.

In this example, we remove the disk named myDisk from the VM myVM in the myResourceGroup resource group. First you remove the disk using the Remove-AzVMDataDisk cmdlet. Then, you update the state of the virtual machine, using the Update-AzVM cmdlet, to complete the process of removing the data disk.

$VirtualMachine = Get-AzVM -ResourceGroupName "myResourceGroup" -Name "myVM"
Remove-AzVMDataDisk -VM $VirtualMachine -Name "myDisk"
Update-AzVM -ResourceGroupName "myResourceGroup" -VM $VirtualMachine

The disk stays in storage but is no longer attached to a virtual machine.

Detach a data disk using the portal

  1. In the left menu, select Virtual Machines.
  2. Select the virtual machine that has the data disk you want to detach and click Stop to de-allocate the VM.
  3. In the virtual machine pane, select Disks.
  4. At the top of the Disks pane, select Edit.
  5. In the Disks pane, to the far right of the data disk that you would like to detach, click the Detach button image detach button.
  6. After the disk has been removed, click Save on the top of the pane.
  7. In the virtual machine pane, click Overview and then click the Start button at the top of the pane to restart the VM.

The disk stays in storage but is no longer attached to a virtual machine.

Next steps

If you want to reuse the data disk, you can just attach it to another VM