Disconnect disk in a running VM

Prosper's picture
Forums: 

disconnecting a disk from a running VM is only possible through Powershell.

$VirtualMachine = Get-AzureRmVM -ResourceGroupName "RG-name" -Name "MyVM-name"
Remove-AzureRmVMDataDisk -VM $VirtualMachine -Name "DataDisk-name"
Update-AzureRmVM -ResourceGroupName "RG-name" -VM $VirtualMachine

After disconnect you can reconnect this disk to another machine or remove the disk from the resourcegroup