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.
Lower latency
In select regions, the disk detach latency has been reduced, so you'll see an improvement of up to 15%. This is useful if you have planned/unplanned failovers between VMs, you're scaling your workload, or are running a high scale stateful workload such as Azure Kubernetes Service. However, this improvement is limited to the explicit disk detach command, Remove-AzVMDataDisk
. You won't see the performance improvement if you call a command that may implicitly perform a detach, like Update-AzVM
. You don't need to take any action other than calling the explicit detach command to see this improvement.
Lower latency is currently available in every public region except for:
- Canada Central
- Central US
- East US
- East US 2
- South Central US
- West US 2
- Germany North
- India West
- North Europe
- West Europe
Detach a data disk using the portal
You can hot remove a data disk, but make sure nothing is actively using the disk before detaching it from the VM.