How to automate Azure Site recovery with VM Replication Using Terraform

Satish B 190 Reputation points
2026-06-17T07:07:26.8266667+00:00

Hi Team,

I’m new to setting up Azure Site Recovery with VM replication. I’ve reviewed a few articles, but it appears that Terraform does not yet fully support all aspects of Azure Site Recovery VM replication.

Could you please suggest the best enterprise-grade approach for automating this setup? If you have any reference materials, examples, or recommended practices, I would greatly appreciate your guidance.

Thank you in advance for your support.

Azure Site Recovery
Azure Site Recovery

An Azure native disaster recovery service. Previously known as Microsoft Azure Hyper-V Recovery Manager.


1 answer

Sort by: Most helpful
  1. Bharath Y P 10,165 Reputation points Microsoft External Staff Moderator
    2026-06-17T11:23:36.51+00:00

    Hello Satish B, You are trying to Automate Azure Site Recovery (ASR) VM replication Using Terraform but noticing gaps in coverage and looking for a scalable, enterprise-grade automation pattern. This is a common challenge Terraform supports core components but not the entire ASR lifecycle consistently.

    Terraform supports Recovery Services Vault, Fabrics, policies, containers and Basic VM replication (Azure-to-Azure). But full workflows (failover, reprotect, orchestration, hybrid scenarios) are not fully declarative. Some operations require: PowerShell, REST APIs and Recovery Plans + Runbooks.

    Also Azure officially supports automation via PowerShell, REST APIs and ARM/Bicep templates. Azure CLI support is limited for ASR.

    azure to azure support matrix

    ASR is orchestration-heavy not just resource creation (like VMs). It involves:

    • Stateful lifecycle
    • Replication state transitions
    • Failover sequencing

    ASR operations are procedura Enable replication > sync > test failover > failover > reprotect. Terraform is declarative—so it struggles with these workflows

    API-first design in ASR, Azure exposes:

    Enterprise-grade approach (recommended pattern)

    1) Use Terraform for what it clearly covers: foundational ASR resources

    From the Terraform-related doc, you can at least automate creation of the Recovery Services vault with Terraform (“Quickstart: Use Terraform to create an Azure Recovery Services vault”).

    In practice, this gives you consistent environment setup:

    • vault + required baseline Azure resources that Terraform can reliably create
    • networking/storage/account prerequisites you choose to manage as code

    2) Use ASR configuration steps (portal/API-driven) for replication enablement details

    Your provided ASR docs emphasize that replication enablement is a step-by-step workflow in ASR:

    • create vault + select replication goal
    • set up source environment / target environment
    • enable replication
    • then run drills and recovery plan testing

    Because those steps are deeply tied to ASR configuration and are called out as explicit workflows in Microsoft guidance, the “best enterprise approach” (given Terraform gaps) is:

    • automate the setup as much as possible (especially vault + prerequisites)
    • for the remaining ASR replication configuration, use the ASR-native workflow (often achievable via supported automation mechanisms, depending on what your environment supports)

    3) Automate recovery execution using Recovery Plans + Automation runbooks (where applicable)

    Your docs also include an approach for automation around recovery plans:

    “Automation runbooks and recovery plans” describes integrating Azure Automation runbooks into recovery plans this lets you convert multi-step recovery actions into a more controlled, repeatable process (a common enterprise requirement)

    Even if “replication enablement” isn’t fully Terraform-covered, this helps you still meet the “automate disaster recovery” goal with a strong operational standard.

    4) Standardize replication policy management as part of your automation runbook/pipeline

    ASR replication policies govern:

    • recovery point frequency
    • retention period
    • multi-VM consistency (when needed)

    The replication policy doc you provided outlines how to set/edit policies in the Recovery Services vault and notes that policy changes apply to existing VMs using that policy. You can incorporate this into your deployment pipeline (even if the mechanism isn’t Terraform for the whole flow).

    References documentation

    Quickstart create vault terraform

    Azure to azure tutorial enable replication

    Automation runbooks and recovery plans

    Overview of Azure Site Recovery

    Troubleshoot replication

    Replication policy / recovery point behavior references surfaced in your doc

    eplicate Azure Stack VMs to Azure; step workflow including enable replication

    Hyper-V to Azure using PowerShell + ARM—automation alternative reference

    Hope this helps. If the information was useful, please consider accepting the answer and upvoting. Feel free to reach out if you need any further assistance. Thank you.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.