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

Note

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.