Terraform + Azure
Terraform (or OpenTofu) provisioning Microsoft Azure through the azurerm provider, with azapi for the newest ARM features and azuread for Entra ID objects.
- Terraform
- Azure
- Learning curve
- Moderate
- Status
- Actively developed
- Reviewed
- November 2026
- Best for
- Organisations standardised on Azure and Entra ID that want Terraform's plan and state workflow
- Multi-cloud teams using one IaC tool across Azure and other providers
- Landing zones: management groups, subscription vending, policy assignments and hub-and-spoke networks
- AKS, App Service and Azure SQL environments replicated across subscriptions
- Not ideal for
- Per-commit application releases
- Azure-only team needing new features on release day
Overview
This stack manages Azure with Terraform's `azurerm` provider, developed by HashiCorp together with Microsoft, usually alongside `azapi` for Azure Resource Manager features that azurerm does not cover yet and `azuread` for Microsoft Entra ID applications, groups and service principals. State lives in an Azure Storage blob, locked with blob leases. Microsoft documents Terraform as a supported way to deploy Azure and publishes Azure Verified Modules for it. Teams choose it over Bicep when they want one tool across clouds or prefer Terraform's plan and state workflow.
What's inside
HCL is the easy part. Azure adds management groups, subscriptions and resource groups, Azure RBAC versus Entra ID roles, private endpoints with private DNS zones, and provider version quirks, most of which surface only as apply-time errors.
Terraform
Infrastructure
Hosts, deploys or connects the system
Learning: Easy
Status: Active
Azure
Infrastructure
Hosts, deploys or connects the system
Learning: Moderate
Status: Active
How it works
Terraform authenticates to Microsoft Entra ID, plans against state held in Azure Storage, and sends requests to Azure Resource Manager, which checks RBAC and Azure Policy and provisions resources through long-running operations Terraform polls.
- 1.
Other to infrastructure
Terraform loads HCL, often built on Azure Verified Modules, and the `azurerm` backend takes a lease on the state blob in a Storage Account so concurrent applies are blocked.
- 2.
Infrastructure to infrastructure
Providers authenticate to Entra ID (Azure CLI locally, managed identity on self-hosted runners, or OIDC workload identity federation from GitHub Actions or Azure DevOps) and target the `subscription_id` set in the provider block (mandatory since azurerm 4.0).
- 3.
Infrastructure to infrastructure
`terraform plan` reads current resources through ARM REST APIs; typed `azurerm` resources such as `azurerm_kubernetes_cluster` sit alongside `azapi_resource` blocks that send raw ARM bodies for a pinned API version.
- 4.
Infrastructure to infrastructure
On apply, ARM evaluates RBAC and Azure Policy for every request; a deny policy, quota limit or missing role assignment fails that resource mid-apply while earlier resources stay created.
- 5.
Infrastructure to infrastructure
Slow resources such as Application Gateway, API Management and VPN gateways return long-running operations that Terraform polls within configurable `timeouts`, then writes the final state back to the blob.
Strengths and drawbacks
Strengths
Typed provider plus day-zero ARM coverage
`azurerm` offers ergonomic, typed resources, while `azapi` can manage any ARM resource type or preview API version immediately, so teams rarely wait for provider support.
Microsoft-backed modules and docs
Microsoft maintains Terraform guidance on Microsoft Learn and Azure Verified Modules, a curated module set with consistent interfaces for common resources and landing zone patterns.
Keyless pipeline authentication
OIDC workload identity federation and managed identities let pipelines authenticate without client secrets that expire or leak.
Identity in the same plan
With the `azuread` provider, app registrations, service principals and group memberships are created alongside the Azure resources and role assignments that depend on them.
Drawbacks
Three providers, three permission models
Azure resources need Azure RBAC, Entra ID objects need Microsoft Graph permissions through `azuread`, and `azapi` bodies must match ARM API versions, so credentials and upgrades are managed per provider.
Slow, partially failing applies
Some Azure resources take tens of minutes to create or update, and a policy denial or quota error mid-apply leaves a half-built environment; re-running apply after fixing the cause is routine.
Major provider upgrades bite
Major azurerm releases rename or remove resources and change defaults (4.0 made `subscription_id` mandatory and changed resource provider registration) and moving a resource from `azurerm` to `azapi` needs a state migration.
Naming rules and global uniqueness
Each resource type has its own naming constraints (storage account names, for example, must be 3-24 lowercase letters and digits and globally unique) so naming conventions and random suffixes are needed from day one.
Bicep is the native competitor
Microsoft's Bicep needs no state file, supports new resource types on release and adds managed cleanup through deployment stacks; Azure-only teams often find it simpler. Terraform's 2023 move to the BSL also leads some teams to OpenTofu.
Scores
Editorial ratings out of 10, comparable across every stack in the guide. They are judgement, not benchmarks. How we score
- Speed of building
- 6.8 out of 10, catalog average 7.7
- Ease of learning
- 6.8 out of 10, catalog average 7.2
- Scalability
- 8.4 out of 10, catalog average 7.6
- Performance
- 7.2 out of 10, catalog average 7.5
- Maintainability
- 7.2 out of 10, catalog average 7.2
- Ecosystem
- 8.0 out of 10, catalog average 8.2
- Flexibility
- 7.8 out of 10, catalog average 7.4
How quickly a team ships features
Higher means easier to pick up
How far it grows before a redesign
Speed of the running application
How well the codebase ages
Libraries, hosting, docs and hiring
How many kinds of product it suits
How it scales
Scales from one subscription to tenant-wide estates by splitting state per management group, subscription and workload, with pipelines sized to stay within ARM request throttling.
- Starting outMVP and first users
- One subscription with a resource group per environment, state in a single Storage Account container, applied from a laptop with Azure CLI credentials.
- GrowingReal traffic, a few engineers
- Separate state per environment and workload, Azure DevOps or GitHub Actions pipelines using OIDC, and Azure Verified Modules for networking, AKS and databases.
- LargeHeavy traffic or data
- Hub-and-spoke networking across subscriptions, provider aliases per subscription, policy-as-code assignments, and plans reviewed through HCP Terraform, Atlantis or pipeline approvals.
- EnterpriseMany teams and regions
- Azure Landing Zones deployed with Terraform modules: management group hierarchy, subscription vending, central policy and logging, with separate identities and state per platform layer.
Where it fits
Common projects, from best fit to worst.
Enterprise landing zone
Management groups, policy assignments, hub networking, logging and subscription vending defined as code and changed through reviewed pull requests.
Great fit
AKS platform per environment
AKS clusters, node pools, Azure Container Registry and role assignments as code; workloads on the cluster are better deployed by Helm or GitOps afterwards.
Good fit
Entra ID app registrations and RBAC
App registrations, service principals, groups and role assignments live next to the resources they grant access to, though Graph permissions for the pipeline need careful scoping.
Good fit
Azure-only team needing new features on release day
Workable through `azapi`, but Bicep's native support and lack of state may be simpler when multi-cloud is not a goal.
Workable
Per-commit application releases
Pushing new App Service or container versions on every commit fits deployment slots, pipelines or GitOps better than full Terraform runs.
Poor fit
Alternatives
Similar stacks, and when you would choose them instead.
- Terraform + AWS
Pick it for AWS-hosted workloads; the AWS provider has the largest module and community ecosystem of the three clouds.
CompareTerraform + Azure with Terraform + AWS - Terraform + Google Cloud
Pick it for Google Cloud, where the project-based hierarchy and built-in GCS state locking make bootstrapping simpler.
CompareTerraform + Azure with Terraform + Google Cloud - Ansible + Linux
Pick it to configure software inside Azure VMs after Terraform creates them, or for estates that are mostly long-lived servers.
CompareTerraform + Azure with Ansible + Linux
Sources
Reviewed on November 19, 2026 against the documentation below. Found something out of date? Suggest a correction. Read our methodology.
- Terraform AzureRM Provider
Official HashiCorp Azure provider docs.
- Terraform on Azure (Microsoft Learn)
Microsoft's guides for authenticating, storing state and deploying Azure with Terraform.
- AzAPI Provider
Microsoft's provider for managing any Azure Resource Manager resource type and API version.
- Azure Verified Modules
Microsoft's curated Terraform and Bicep module set.
- OpenTofu documentation
MPL-licensed fork of Terraform under the Linux Foundation.
Related stacks
Stacks that share technologies with Terraform + Azure.