Azure Docs

Migrating Azure Managed Disks

This document provides guidance on migrating your Azure Managed Disks. We cover various scenarios, including migrating from unmanaged disks to managed disks, migrating disks between subscriptions or regions, and moving data to different disk types.

Note: Migrating disks can involve downtime. Plan your migration carefully to minimize impact on your applications and services.

1. Migrating from Unmanaged Disks to Managed Disks

This is a common migration path for older deployments. Azure provides tools to automate this process.

Methods:

# Example using Azure CLI for conversion
az vm deallocate --resource-group MyResourceGroup --name MyVM
az vm convert --resource-group MyResourceGroup --name MyVM --out managed
az vm start --resource-group MyResourceGroup --name MyVM

2. Migrating Managed Disks Between Regions

Moving managed disks to a different Azure region often involves creating a copy of the disk in the target region.

Steps:

  1. Create a Snapshot: Take a snapshot of the source managed disk.
  2. Copy Snapshot to Target Region: Use the az snapshot create command with the --location parameter to copy the snapshot to the desired region.
  3. Create Managed Disk from Snapshot: Create a new managed disk in the target region from the copied snapshot.
  4. Attach to VM: Attach the new managed disk to a VM in the target region.
Tip: For large disks, consider using Azure Site Recovery for a more robust disaster recovery and migration solution.

3. Migrating Managed Disks Between Subscriptions

Migrating disks across subscriptions typically involves exporting the VHD and then importing it into the target subscription.

Process:

Important: Ensure you have the necessary permissions in both the source and target subscriptions.

4. Migrating to Different Disk Types (e.g., HDD to SSD)

You can upgrade or downgrade the performance tier of your managed disks by migrating data to a new disk of the desired type.

Recommended Approach:

  1. Create a new disk of the target type (e.g., Premium SSD).
  2. Migrate data from the old disk to the new disk. This can be done using tools like Robocopy (for Windows) or rsync (for Linux) while the VM is running or in a maintenance window.
  3. Detact the old disk and attach the new disk to your VM.
  4. Update boot order or mount points if necessary.
  5. Delete the old disk once you confirm the new disk is functioning correctly.

Alternatively, you can create a snapshot, create a new disk from the snapshot with the desired type, and then swap the disks.

Tools and Considerations

Tool/Service Use Case Notes
Azure Portal Simple conversions, basic operations User-friendly, good for smaller migrations.
Azure CLI/PowerShell Automation, scripting complex migrations Highly flexible, recommended for production environments.
Azure Resource Manager (ARM) Templates Infrastructure as Code, consistent deployments Enables repeatable and automated deployments.
Azure Site Recovery Disaster Recovery, large-scale migrations Provides replication and failover capabilities.
Azure Migrate Discovery, assessment, and migration planning Comprehensive tool for modernizing infrastructure.

Best Practices