Jeffrey
Jeffrey

Reputation: 2159

Azure: Detach unmanaged disks, move to another storage account and reattach to same VM

I have 1 x OS disk and 1 x Data disk attached to VM1, the disks are unmanaged in storage account mystorage

So I know I cannot rename the storage account...

Can I instead do the following then somehow re-attach them to the Original VM again?

  1. Stop VM1
  2. In Azure Storage Explorer, for each of the disks, Break Lease
  3. In Azure Storage Explorer, copy each disk from mystorage to mynewstorage

The only thing im not sure on how to do is re-attach them to the VM1

Upvotes: 0

Views: 2808

Answers (3)

blancos
blancos

Reputation: 25

Your process is right so far.

  1. Stop the VM

  2. Detach disks from VM1

  3. Break lease and copy disks like you indicated.

  4. Reattach disks to VM1: Once the disks are copied to the new storage account, navigate to VM1 in the Azure portal. Select "Disks" from the settings menu. Click on "Attach existing" at the top. Choose the disk, specify the disk name, and confirm the action.

  5. Start VM1: After reattaching the disks, start VM1.

Upvotes: 0

Matthew McEnroe
Matthew McEnroe

Reputation: 1

You could create a snapshot of the OS disk, move the snapshot to the new storage account and create the VM , that way you would keep the OS disk.

Upvotes: 0

4c74356b41
4c74356b41

Reputation: 72191

yeah, this is a valid approach, you dont need to break the lease if you deallocate the vm (at least that is my impression).

you can use az cli to attach unmanaged disk (https://learn.microsoft.com/en-us/cli/azure/vm/unmanaged-disk?view=azure-cli-latest#az-vm-unmanaged-disk-attach) or portal ui (https://cloud.netapp.com/blog/azure-virtual-machines-attach-mount) or powershell

Upvotes: 0

Related Questions