Loading...

Effortlessly Migrate Azure VMs between zones

Effortlessly Migrate Azure VMs between zones

For various reasons you might come across a situation when you need to migrate your Azure VMs from one zone to another. Migrating Azure VMs between zones can be a daunting and time-consuming task, especially when done manually. I’m excited to share the Python tool I’ve developed that simplifies the process of migrating VMs along with its data disks across zones within Microsoft Azure.

 

The Challenge of VM migration

Migrating VMs specially along with its data disks, between zones can be a daunting task. It involves creating snapshots, creating disks from the snapshots in the new zone, creating VMs using those disks and ensuring that all configurations are correctly set up in the new zone. This process is not only time-consuming but also prone to errors if done manually.

 

Introducing the Azure VM Migration Tool

To address this challenge, I’ve created a Python script that automates the entire migration process. The tool takes snapshots of the disks attached to a VM in one Azure zone, create new disks using those snapshots in another zone, and create new VM using those disks in another zone and handling all the necessary steps in between. All you need to do is to provide necessary information in a CSV file and it will take care of all the complex tasks.

 

Key Features

  • Snapshot Creation: The tool automatically creates snapshots of the disks attached to a VM, ensuring that a consistent state of the disk is captured for migration.
  • Disks creation in target zone: It then creates disks in the target zone using the snapshots and abstract away the complexity of this operation.
  • Create VM and attach data disks: Now new VMs are being created in the new zone and all disks are attached to the new VM.
  • Logging: Throughout the process, the tool provides detailed logging, making it easy to monitor the migration and troubleshoot any issues that may arise.

 

How It Works

The script requires minimal setup. Users need to provide a CSV file with following information. A sample CSV has also been shared in the repository.

 

  1. Names of the source VMs
  2. Source VM Resource Group
  3. Operating system type
  4. New Resource Group where new VMs need to be created
  5. Target zone where VMs need to be created
  6. Size of the new VM.

 

Apart from the above information, following information also needs to be provided in the script.

 

  1. Virtual Network Name
  2. Subnet Name
  3. Virtual Network

The tool then performs the following steps:

1. Capture Subnet ID: It starts by capturing the subnet ID that will be used in the VM creation process in the target zone.
2. Create Snapshot: The tool creates snapshots of the disks attached to the VM.
3. Create disks from the snapshot: The snapshots are then used to create disk in the target zone.
4. Create VM and Attach Disks: Finally, the new OS disk is used to create new VM in the target zone and the data disks are attached to the VM.

 

Getting Started

To use the tool, you’ll need Python 3.6.x and the Azure CLI installed on your machine. Then, simply run the script with `python az_vm_migration_tool.py`, passing the name of a CSV file containing the migration parameters as an argument.

 

Github repo

panwar28/azure_vm_migration_tool: This tool helps you migrate Azure VMs between zones in a bulk. You provide your inputs in CSV, run the tool and sit back and relax. It will do its job. (github.com)

 

Conclusion

The Azure VM Migration Tool represents a significant step forward in simplifying the process of migrating VMs within Azure. By automating the migration process, it not only saves time but also reduces the potential for errors, making it an invaluable resource for anyone managing Azure VMs.

Published on:

Learn more
Azure Compute Blog articles
Azure Compute Blog articles

Azure Compute Blog articles

Share post:

Related posts

Azure Developer CLI: Azure Container Apps Dev-to-Prod Deployment with Layered Infrastructure

This post walks through how to implement “build once, deploy everywhere” patterns using Azure Container Apps with the new azd publ...

13 hours ago

Accelerate Your Growth: Azure Cosmos DB Partner Acceleration Program

Accelerate Your Growth: Azure Cosmos DB Partner Acceleration Program Unlock 360° Success with the Cosmos DB Engineering Team Are you ready to ...

2 days ago

Transforming Field Operations with AI, Azure Maps & Dynamics 365

Efficient field operations are the backbone of successful, data-driven organizations. Yet, many businesses continue to struggle with scattered...

4 days ago

Failures Happen in Cloud, but how Azure Cosmos DB keeps your Applications Online

The only thing that’s constant in distributed systems is failures. No cloud platform is immune to failures — from regional outages and transie...

5 days ago

The `azd` extension to configure GitHub Copilot coding agent integration with Azure

This post shares how to set up the GitHub Copilot coding agent integration with Azure resources and services by using the Azure Developer CLI ...

5 days ago

Announcing Azure MCP Server 1.0.0 Stable Release – A New Era for Agentic Workflows

Today marks a major milestone for agentic development on Azure: the stable release of the Azure MCP Server 1.0! The post Announcing Azure MCP ...

7 days ago

From Backup to Discovery: Veeam’s Search Engine Powered by Azure Cosmos DB

This article was co-authored by Zack Rossman, Staff Software Engineer, Veeam; Ashlie Martinez, Staff Software Engineer, Veeam; and James Nguye...

7 days ago

Azure SDK Release (October 2025)

Azure SDK releases every month. In this post, you'll find this month's highlights and release notes. The post Azure SDK Release (October 2025)...

8 days ago

Microsoft Copilot (Microsoft 365): [Copilot Extensibility] No-Code Publishing for Azure AI Foundry Agents to Microsoft 365 Copilot Agent Store

Developers can now publish Azure AI Foundry Agents directly to the Microsoft 365 Copilot Agent Store with a simplified, no-code experience. Pr...

9 days ago
Stay up to date with latest Microsoft Dynamics 365 and Power Platform news!
* Yes, I agree to the privacy policy