Maintain static IP addresses during migration (preview)
Applies to: Azure Local 2311.2 and later
This article explains how to preserve static IP addresses during virtual machine (VM) migration to Azure Local using Azure Migrate. It provides detailed instructions for running the static IP migration scripts on Windows VMs, and supporting guest operating systems from Windows Server 2012 R2 and later. This applies to both Hyper-V migration and VMware migration.
About the static IP migration package
Download the Windows static IP migration package (.zip format).
The .zip file includes the following scripts:
Prepare-MigratedVM.ps1 – Prepares the VM for static IP migration using the
-StaticIPMigration
cmdlet, which runs the Initialize-StaticIPMigration.ps1 script.Logs are automatically created in the script's directory.
Initialize-StaticIPMigration.ps1 - Collects the VM network interface information into a configuration file (InterfaceConfigurations.json in the local directory) and sets up a scheduled task to run the Set-StaticIPConfiguration.ps1 script.
Set-StaticIPConfiguration.ps1 - Runs at VM startup to apply the network interface configuration file generated.
Utilities.psm1 - Contains helper functions for the scripts.
Note
Static IP address migration is currently available only for Windows VMs, and is not supported for Linux VMs.
Prerequisites
Before you begin, prepare the source and target environments for IP migration.
Prepare source VMs for IP migration
To migrate VMs with static IPs from the source system (Hyper-V or VMware), follow these steps:
Ensure the VMs are powered on throughout the replication process and up to planned failover (migration).
For VMware VMs, ensure that VMware Tools are installed.
For Hyper-V VMs, ensure that Hyper-V Integration Services are installed. For more information, see Manage Hyper-V Integration Services.
For Linux VMs, ensure that Linux Integration Services are installed.
Ensure the preparation script is run on the source VM by an account with administrator privileges to create scheduled tasks.
Prepare target VMs for IP migration
On the target system, provision a static Azure Arc logical network to support the migration. This setup requires defining the IP address space, gateway address, DNS servers, and optionally an IP pool range.
For detailed guidance on creating and configuring static or dynamic Azure Arc logical networks, see Create logical networks for Azure Local.
(Optional) Prepare to deploy IP migration at scale using group policy
To use this method, you need domain administrator privileges and access to the Group Policy Editor. Additionally, one of the following conditions must be met:
The source VMs must have internet access to download the static IP migration package directly to their local file system.
The source VMs must have read-only access to a remote file share hosting the static IP migration package, which must be prepared and downloaded to the remote share in advance.
Set up IP migration manually
Download the .zip file and install the static IP migration package contents onto a local folder on the VM.
Open a PowerShell console and run the Prepare-MigratedVM.ps1 script with the following command:
.\Prepare-MigratedVM.ps1 -StaticIPMigration
In Azure portal, create a migration project, trigger discovery, and replicate the VM. For more information, see Create an Azure Migrate project.
Before you select the VMs to migrate, use the Replication Wizard to assign and configure the correct logical networks for each network interface on the source VM.
In the Replications > General > Compute and Network section, select VM. On this tab, ensure that the network interfaces are assigned to the correct logical network. DHCP network interfaces are assigned to dynamic logical networks, and static network interfaces are assigned to static logical networks.
Failure to correctly assign the network interfaces to their corresponding logical networks results in incorrect IP address information displayed in Azure Arc and Azure portal.
On the Migrate view, under Shut down virtual machines, select Yes, shut down virtual machines (ensures no data loss).
After the VM is migrated, check the migrated VM to verify that the static IP settings were migrated over.
Set up IP migration using group policy
Follow these steps to set up static IP migration at scale on domain-joined VMs using group policy.
- Review the prerequisites listed for static IP migrations using group policy.
Create a group policy object
Open the Group Policy Management Console for your Active Directory (AD) environment.
In your AD forest, navigate to the location that contains the VMs you want to migrate with preserved static IPs.
Right-click and select Create a GPO on this domain, and Link it here.
When prompted, assign a descriptive name to this GPO:
Edit the GPO:
Right-click the newly created GPO and select Edit.
In the Group Policy Management Editor, go to Computer Configuration > Preferences > Control Panel Settings > Scheduled Tasks.
Right-click the blank area under Scheduled Tasks and select New > Immediate Task (At least Windows 7).
Define the scheduled task
Select New > Immediate Task. When the Scheduled Task Wizard opens, configure each tab as follows:
On the General tab, under Action, select Create and enter a descriptive name for the task.
Under Security Options, select the following settings:
When running the task, use the following user account NT AUTHORITY\SYSTEM.
Select Run whether user is logged on or not.
SelectRun with highest privileges.
Under Configure for, select Windows Vista or Windows Server 2008 for configuration:
On the Actions tab, select New under the Actions tab.
Under Action, select Start a program.
Under Settings:
Run Program/script: Type powershell.exe.
If your VMs can access the download link for the .zip file, add the following arguments, replacing the parameters in brackets:
-ExecutionPolicy Bypass -Command "Invoke-WebRequest -Uri [download link] -OutFile [path to static IP migration package] ; Expand-Archive Path [path to static IP migration package] -DestinationPath C:\StaticIp ; & C:\StaticIp\Prepare-MigratedVM.ps1 -StaticIPMigration ```
(Alternate) If you have a remote share hosting the .zip file, add the following arguments, replacing the parameters in brackets:
-ExecutionPolicy Bypass -Command "Copy-Item -Path [ZIP file path in remote share] -Destination [path to static IP migration package] -Force ; Expand-Archive -Path [path to static IP migration package] DestinationPath C:\StaticIp ; & C:\StaticIp\Prepare-MigratedVM.ps1 -StaticIPMigration
Select an Action, Program/script, add optional arguments, and optional Start in information as shown:
Select OK to finalize the scheduled task configuration.
Apply the group policy object
Link the GPO to the desired Organizational Unit (OU):
If the GPO is not already linked, right-click the desired OU in the Group Policy Management Console and select Link an existing GPO.
Select the GPO you created.
Wait for replication to complete. After 10-20 minutes, the group policy object replicates to the respective domain controllers. You can also force the policy update by running the
gpupdate
cmdlet in PowerShell on a specific VM.Verify the changes:
Check the VM to confirm that an interface configuration file has been created under C:\StaticIp\IpConfigurations.json.
Ensure that a scheduled task named
Set-StaticIpConfiguration
has been created to run on restart.
Known limitations
These are the known limitations and display issues when migrating static IP addresses:
Old network adapter information in Device Manager
After migration, Device Manager may still display the old network adapter information from pre-migration. While this does not affect the new network adapter created post-migration and will not cause IP conflicts, the script doesn't currently delete this old registration, so it remains visible.
Multiple IP addresses on a single network adapter
When the source VM has multiple static IP addresses assigned to a single network adapter, those IP addresses are correctly assigned on the migrated VM. However, Arc VMs in Azure Local will display only one IP address per network adapter in Arc portal. This is a known display issue in the Arc portal and does not affect the actual functionality of the IP addresses on the migrated VM.
Multiple network adapters and types
If the source VM has multiple network adapters with a mix of DHCP and static configurations, the migrated VM will preserve the correct number of network adapter, network adapter types, and static IP addresses on the static network adapter. However, the Arc portal view of the migrated VM may incorrectly display duplicate or inaccurate IPs on the network adapters. This is a known display issue in the Arc portal and doesn't impact the functionality of the IP addresses on the migrated VM. See the example below of a migrated VM with a DHCP network adapter and a static network adapter.