JIMITH
JIMITH

Reputation: 37

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?

Upvotes: 0

Views: 6312

Answers (2)

EZR
EZR

Reputation: 73

I believe you cannot rename the Azure resources, however I have bumped into the same situation today for the OS disk and performed the below steps to achieve it from Azure portal.

  1. Take a snapshot of the current OS disk in the same RG where the VM exists.
  2. Stop the VM.
  3. Create a new disk using the snapshot with the desired name/rename.
  4. Go to the Disks of the stopped VM and Swap OS disk
  5. Choose disk should show up the disk, created in step#3

PS: I had to wait a little bit for portal to show up the new disk in step# 5. I had to wait ~15 minutes.

Upvotes: 0

Charles Xu
Charles Xu

Reputation: 31452

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.

Upvotes: 1

Related Questions