Search code examples
azurepowershellazure-virtual-machineazure-powershellazure-disk

Rename Virtual Machine Managed Disks on Microsoft Azure through PowerShell


How to Rename Virtual Machine Managed Disks on Microsoft Azure through PowerShell?

I tried with,

Update-AzureRmDisk 

But I'm not able to change the name,

How can I do that?


Solution

  • There is no command the change the managed disk directly. So you cannot do that with one command.

    But there is always another way to achieve that. And the solution follow five steps below:

    1. Determine the Virtual Machine ARM template
    2. Delete the Virtual Machine
    3. Copy disks with new names
    4. Re-create the Virtual Machine and attach to disk copies
    5. Delete original disks

    The solution we lay out here is based on ARM template. You could accomplish something similar using PowerShell or Command Line Interface (CLI) scripts. For more details, see Renaming Virtual Machine Disks.