How do you handle Azure Migrate VMs in a Terraform managed environment?

November 17, 2026 4 answers
Asked by 7k!marblethimble_462

We currently let Azure Migrate create target VMs, then import them into Terraform. Importing works, but getting the configuration to match our existing modules is still a lot of work.

Is there a practical way to have Terraform create the target infrastructure first, or is post-migration import the better route at scale?

Answers

p.692~tramspindle

I would plan around automated discovery and import rather than assume Azure Migrate can move a workload into a precreated VM. Check the supported workflow for your migration scenario before designing around that.

After migration, collect the resource IDs and generate import blocks for the resources your modules will own. Import only brings existing objects into state. It does not make the module configuration match them. You'll still need to map things like VM size, disks, network interfaces and settings to the module inputs, then review the plan for changes you don't intend.

For a large batch, that mapping and plan review are probably the bigger automation targets than the imports themselves.

7k!marblethimble_462:

That mapping is the part I'm most concerned about. The migrated resources need to fit established modules, not just exist in state.

Reply to this answer
_h49~puddlecrank.6

Another option to investigate is Terraform building the surrounding infrastructure, with the migrated disks used to recreate the VM under Terraform management. That is a different workflow from Azure Migrate deploying directly into an existing VM.

Test it on a representative workload first. Recreating the VM from disks can mean a longer maintenance window, and you'll need to check the disk, network and VM settings carefully.

Reply to this answer
Pexlin-6q

I'd separate the infrastructure question from guest configuration. Terraform can track the Azure resources, but it isn't a substitute for configuring and maintaining the operating system and applications inside the VMs.

That doesn't mean the VMs shouldn't be in Terraform. Just decide which settings belong in the modules and which need a configuration management process, rather than trying to make one tool do everything.

Reply to this answer
Rilvona+7c

It may also be worth asking which workloads really need to stay as VMs. A lift and shift can get things moving when time is tight, but it doesn't have to be the final architecture. Modernization can happen separately as capacity allows.

6s~cobaltshoelace_417:

That makes sense as a longer-term goal. It doesn't remove the need for a repeatable import process while the VM migrations are underway, though.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions