📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

How do you choose between Bicep, ARM templates, Terraform (or OpenTofu) and Pulumi for a .NET team? Compare how each handles state, multi-cloud and non-Azure resources, the skills it needs, and the Terraform licence change, and tell me what you would pick for an Azure-first Australian organisation.

Covers Bicep, ARM JSON, Terraform, OpenTofu and Pulumi compared on state management, provider coverage, multi-cloud, language and team skills, licensing (Terraform BSL, IBM ownership, OpenTofu MPL), previews and the decision for an Azure-first team.

Mid-Level Theory Intermediate bicep devops infrastructure-as-code opentofu pulumi terraform

🎯 Key points

  • Bicep compiles to ARM JSON: native Azure support, day-zero API versions, implicit dependency graph from symbolic references, no state file to run
  • ARM JSON is the engine format; nobody should hand-write it in new work
  • Terraform/OpenTofu keep a state file: remote backend (Azure Storage with blob lease locking), versioned, protected, can hold secrets
  • State has operational cost: locking contention, refresh time on large states, import / state mv / moved-block surgery
  • Terraform licence: MPL 2.0 to BSL 1.1 in August 2023 (internal use still allowed); IBM completed the HashiCorp acquisition on 27 February 2025
  • OpenTofu: MPL 2.0 fork under the Linux Foundation, accepted as a CNCF sandbox project in April 2025
  • Pulumi uses C#, TypeScript or Python with a state backend; great for .NET skills, risk of over-clever code
  • Azure-only team: Bicep plus deployment stacks; multi-provider platform team: Terraform/OpenTofu; decide on resources managed and skills

⏱ 30-second answer

Bicep is Azure's own language: it compiles to ARM JSON, has no state file (ARM holds the live state), supports new Azure features on day one, and with deployment stacks can track and clean up what it owns. Terraform (and its open-source fork OpenTofu) uses HCL and a state file, and its strength is providers for almost everything: Azure, AWS, GitHub, Cloudflare, Entra ID. Pulumi gives you the same model in C# or TypeScript.

  • Terraform moved to the Business Source Licence in 2023 and is now owned by IBM; OpenTofu stays MPL 2.0.
  • ARM JSON is the compile target, not something to write by hand.

For an Azure-only team I default to Bicep; if we manage non-Azure resources or multiple clouds, Terraform or OpenTofu. The trade-off is simplicity versus reach.

🗣 Full answer (senior)

How I would answer this in an interview

"I frame it as three questions: what are we managing, who is writing it, and how much state do we want to look after. Bicep is a thin, type-safe language over ARM templates: you write Bicep, it compiles to ARM JSON, and Azure Resource Manager does the work. There is no state file; ARM is the state. New Azure resource types and API versions work immediately because Bicep just targets the ARM API, and since deployment stacks went GA you can also get 'delete what I removed from the template' behaviour and deny settings, with what-if previews for stacks too. Nobody should write raw ARM JSON for new work any more.

Terraform uses HCL and providers. The azurerm and azapi providers cover Azure, but the same tool also manages GitHub repositories, Cloudflare DNS, Entra app registrations, Datadog monitors or AWS. The cost is the state file: it lives in a remote backend, usually an Azure Storage container with blob-lease locking, it can contain secrets, and if it gets out of sync with reality you are doing terraform import and state mv surgery. Licensing matters in procurement conversations: HashiCorp moved Terraform from MPL 2.0 to the Business Source Licence in August 2023, IBM completed its acquisition of HashiCorp in February 2025, and OpenTofu is the MPL-licensed fork under the Linux Foundation. For a normal company using Terraform internally the BSL is not a blocker, but some government and vendor teams prefer OpenTofu. Pulumi is the same desired-state model written in C#, which .NET teams like, with the risk that infrastructure becomes clever object-oriented code nobody can review.

For an Azure-first Australian organisation I'd pick Bicep unless there is a clear reason not to, and Terraform or OpenTofu when the platform team manages several clouds or many non-Azure resources. The mistake I see is choosing the tool on popularity rather than on what you manage and who maintains it."


Side by side (as of late 2026)

Bicep ARM JSON Terraform OpenTofu Pulumi
Language Bicep DSL JSON HCL HCL (compatible) C#, TS, Python, Go, YAML
State ARM (none to manage); stacks for ownership ARM State file, remote backend State file, optional state encryption Pulumi Cloud or self-managed backend
Preview what-if (incl. stacks) what-if plan plan preview
Coverage Azure (plus extensions such as Microsoft Graph) Azure Thousands of providers Same providers via its registry Many providers, native Azure
New Azure features Day zero Day zero Provider release, or azapi day zero Same as Terraform azure-native generated quickly
Licence MIT n/a BSL 1.1 MPL 2.0 Apache 2.0 (engine)

Which to pick

Situation Pick Why
Azure only, app teams own infra Bicep Least moving parts, no state to protect
Platform team, Azure + GitHub + DNS + monitoring Terraform or OpenTofu One tool, one workflow for everything
Licence-sensitive vendor or public sector OpenTofu (or Bicep) Open-source licence, community governance
Strong C# team, complex generated infra Pulumi Real language, tests with xUnit
Legacy ARM JSON estate Decompile to Bicep (az bicep decompile) Clean up gradually

Production example

A common pattern: application teams own their resources in Bicep inside each service repo, while a small platform team uses Terraform for landing zones, GitHub organisation settings and DNS. Each team deploys in minutes, and the platform team's state lives in a locked, private storage account with versioning and soft delete, so a bad state write can be rolled back.

🔍 What the interviewer is checking

Checks whether the candidate can choose an IaC tool on engineering and organisational grounds, and understands state, coverage and licensing accurately.

Green flags

  • Explains state: Bicep relies on ARM, Terraform needs a protected remote backend
  • States the licence facts correctly (BSL 2023, IBM 2025, OpenTofu MPL)
  • Chooses based on resources managed and team skills
  • Mentions previews (what-if, plan) and one owner per resource

Red flags

  • Says Bicep and ARM are different engines, or that Bicep has a state file to manage
  • Recommends hand-written ARM JSON
  • 'Terraform because it is multi-cloud' with no multi-cloud need

📚 Learn in depth

1. Two models of state

Bicep / ARM                              Terraform / OpenTofu / Pulumi
-----------                              -----------------------------
 template ──► ARM ──► live resources        code ──► plan ──► provider ──► live resources
                │                                    ▲
          deployment history                         │
          (stacks: managed list                 state file
           of owned resources)            (address ↔ resource id, attributes)
  • ARM incremental mode only touches resources named in the template. Remove a resource from the template and it stays in Azure. Complete mode deletes anything in the resource group not in the template (dangerous). Deployment stacks are the modern middle ground: Azure records which resources the stack owns, and actionOnUnmanage decides whether removed ones are detached or deleted; denySettings can stop people editing or deleting them outside the stack.
  • Terraform decides what to change by comparing code with state, after refreshing state from reality. That is why it can delete a resource you removed from code, and why a stale or corrupted state is dangerous.

2. Looking after Terraform state on Azure

  1. Backend azurerm pointing at a dedicated storage account, use_azuread_auth = true so no account key is needed.
  2. Locking uses a blob lease; two applies cannot run at once.
  3. Blob versioning and soft delete on, private endpoint, only the pipeline identity has write.
  4. One state per environment and per component (not one giant state) to limit blast radius and lock contention.
  5. State can contain sensitive values (generated passwords, keys); treat it as a secret. OpenTofu can encrypt state client-side.

3. Licensing timeline (check before quoting)

  • August 2023: HashiCorp relicensed Terraform from MPL 2.0 to BSL 1.1, restricting use in products that compete with HashiCorp.
  • September 2023: the community fork, first called OpenTF, became OpenTofu under the Linux Foundation, MPL 2.0.
  • February 2025: IBM completed the HashiCorp acquisition; the BSL stayed.
  • April 2025: OpenTofu accepted as a CNCF sandbox project.
  • The two remain largely compatible (HCL, state format, providers), but features now diverge (for example OpenTofu's state encryption).

For internal use the BSL rarely matters; it matters if you build a product or service that offers Terraform-like functionality, or if your organisation's open-source policy requires OSI licences.

4. Coverage and new features

  • Bicep targets ARM API versions directly, so a resource is available the day its API ships.
  • The azurerm provider wraps resources by hand, so new features can lag; the azapi provider calls ARM directly and closes the gap.
  • Terraform and Pulumi can manage things Bicep cannot: GitHub, Cloudflare, PagerDuty, AWS, Kubernetes objects. Bicep extensions cover some (Microsoft Graph for Entra objects).

5. Pulumi and real languages

Pulumi lets you write loops, functions and unit tests in C#. That helps generated or highly repetitive infrastructure, but reviewers must read general-purpose code to understand what will be deployed, so keep it boring: no deep inheritance, no hidden network calls.

6. Decision factors in order

  1. What resources do you manage (Azure only, or more)?
  2. Who maintains it (app developers or a platform team)?
  3. Operational cost of state (backend, locking, recovery).
  4. Licence and procurement constraints.
  5. Existing estate and skills.

Try it yourself

  1. Write the same storage account in Bicep, Terraform and Pulumi C# (see the code example) and deploy each to a sandbox resource group.
  2. Run terraform state list and terraform state show and read what is stored, including any sensitive attributes.
  3. Delete the storage account in the portal, then run terraform plan and az deployment group what-if and compare how each tool reports it.
  4. Run az bicep decompile on an old ARM JSON template and review the result.
  5. Create a deployment stack with az stack group create --action-on-unmanage detachAll, remove a resource from the template, and redeploy.

💻 Code

The same hardened storage account in three tools.

// Bicep: no backend, ARM is the state
param location string = resourceGroup().location

resource st 'Microsoft.Storage/storageAccounts@2023-05-01' = {
  name: 'stordersprod${uniqueString(resourceGroup().id)}'
  location: location
  sku: { name: 'Standard_ZRS' }
  kind: 'StorageV2'
  properties: {
    minimumTlsVersion: 'TLS1_2'
    allowBlobPublicAccess: false
    allowSharedKeyAccess: false
  }
}
# Terraform / OpenTofu: the state backend is the first thing you design
terraform {
  required_providers {
    azurerm = { source = "hashicorp/azurerm", version = "~> 4.0" }
  }
  backend "azurerm" {
    resource_group_name  = "rg-tfstate-prod"
    storage_account_name = "sttfstateprod"
    container_name       = "tfstate"
    key                  = "orders/prod.tfstate" # one state per component and env
    use_azuread_auth     = true                  # Entra auth, no storage key
  }
}

provider "azurerm" {
  features {}
  # azurerm v4 needs a subscription: set ARM_SUBSCRIPTION_ID in the pipeline
}

resource "azurerm_resource_group" "orders" {
  name     = "rg-orders-prod"
  location = "australiaeast"
}

resource "azurerm_storage_account" "orders" {
  name                            = "stordersprod01"
  resource_group_name             = azurerm_resource_group.orders.name
  location                        = azurerm_resource_group.orders.location
  account_tier                    = "Standard"
  account_replication_type        = "ZRS"
  min_tls_version                 = "TLS1_2"
  allow_nested_items_to_be_public = false
  shared_access_key_enabled       = false

  lifecycle {
    prevent_destroy = true # plan fails instead of deleting production data
  }
}
// Pulumi in C# (Pulumi.AzureNative). State lives in the configured Pulumi backend.
using Pulumi;
using Pulumi.AzureNative.Resources;
using Pulumi.AzureNative.Storage;
using Pulumi.AzureNative.Storage.Inputs;

return await Deployment.RunAsync(() =>
{
    var rg = new ResourceGroup("rg-orders-prod", new() { Location = "australiaeast" });

    var storage = new StorageAccount("stordersprod", new()
    {
        ResourceGroupName = rg.Name,
        Kind = Kind.StorageV2,
        Sku = new SkuArgs { Name = SkuName.Standard_ZRS },
        MinimumTlsVersion = MinimumTlsVersion.TLS1_2,
        AllowBlobPublicAccess = false,
        AllowSharedKeyAccess = false,
    }, new CustomResourceOptions { Protect = true }); // like prevent_destroy

    return new Dictionary<string, object?> { ["storageAccount"] = storage.Name };
});

⚠ Common mistakes

  • Mistake: Keeping Terraform state on a laptop or in Git. Why it is wrong: No locking, easy to lose, and it can contain secrets. Instead: A remote azurerm backend with Entra auth, blob-lease locking, versioning and soft delete.
  • Mistake: One giant state for the whole estate. Why it is wrong: Every plan is slow, locks block other teams, and one mistake has a huge blast radius. Instead: Split state by component and environment.
  • Mistake: Hand-writing ARM JSON for new work. Why it is wrong: Verbose, error-prone and hard to review. Instead: Write Bicep; decompile legacy ARM to Bicep when you touch it.
  • Mistake: Saying 'Terraform is no longer open source, so we cannot use it'. Why it is wrong: The BSL 1.1 restricts offering Terraform as part of a product or hosted service that competes with HashiCorp (now IBM). Using Terraform internally to deploy your own infrastructure, including in a commercial company, is permitted. Instead: Check whether your organisation's policy requires OSI-approved licences or whether you build a competing product; if so, OpenTofu is the near drop-in option.
  • Mistake: Picking Terraform for an Azure-only team because 'it is multi-cloud'. Why it is wrong: You pay the state-management cost for portability you never use. Instead: Choose on what you actually manage.
  • Mistake: Mixing tools on the same resource (Bicep and Terraform both managing one Key Vault). Why it is wrong: They fight: each deployment reverts the other's settings. Instead: One owner per resource; reference others as read-only data sources or existing.
  • Mistake: Writing Pulumi like application code, with inheritance and runtime lookups. Why it is wrong: Reviewers can no longer see what will be deployed. Instead: Keep it declarative and rely on pulumi preview in the PR.
  • Mistake: Using Bicep complete mode to clean up removed resources. Why it is wrong: It deletes everything in the resource group that is not in the template, including things other teams created. Instead: Deployment stacks with an explicit actionOnUnmanage.

🏛 Senior insight: trade-offs

The real cost difference is operational. Bicep pushes state onto Azure: ARM holds the live resources and deployment history, so there is nothing to back up, lock or repair. Terraform, OpenTofu and Pulumi make you run state as a production system:

  • Availability and access: a storage account (or Pulumi Cloud) that every pipeline depends on, with private networking, Entra-only access and versioning.
  • Concurrency: one apply per state at a time; a large shared state becomes a queue for every team.
  • Performance: plan time grows with the number of resources refreshed; states with thousands of resources take minutes per plan, so you split by component.
  • Repair: refactors need moved blocks, adopting existing resources needs import, and a corrupted or stale state means restoring a blob version and reconciling by hand.
  • Security: state can contain secrets, so it is in scope for access reviews and the Privacy Act / Essential Eight conversations.

That cost is worth paying when one tool must manage Azure plus GitHub, DNS and monitoring, and it is overhead when a team only deploys to Azure. Licensing is a procurement question, not an engineering one: know the facts (BSL since August 2023, IBM since February 2025, OpenTofu under the Linux Foundation and CNCF) and let policy decide between Terraform and OpenTofu.

Whatever you choose, standardise: one tool per layer, shared modules (Azure Verified Modules exist for both Bicep and Terraform), the same preview-and-approve pipeline, and drift checks on a schedule.

Option When it fits Cost When not to
Bicep (+ stacks) Azure-only, app teams own infra Azure-only skills Many non-Azure resources
Terraform Multi-provider platform teams, existing HCL estate State operations, BSL review Small Azure-only teams
OpenTofu As Terraform, with OSI licence requirement Same state cost, smaller vendor ecosystem You rely on HCP Terraform features
Pulumi Strong C# team, generated or highly repetitive infra Backend, code-review discipline Teams new to IaC

Measure the choice by lead time for an infrastructure change, plan duration, failed-apply rate, and hours spent on state or drift repair per quarter.

🔗 Follow-ups the interviewer may ask

  1. When: Candidate talks about state or drift without defining it. Why: Checks the candidate can explain the basics of declarative IaC and drift behind the tool choice.
    How to answer

    Infrastructure as code (IaC) means the cloud resources an app needs (App Service, Azure SQL, Key Vault, role assignments) are described in version-controlled files and created by a tool such as Bicep or Terraform, not by clicking in the portal. Good IaC is declarative (you describe the desired end state and the tool works out the API calls) and idempotent (running it again changes nothing if nothing changed). That gives you repeatable environments, a reviewable history in Git, and a way to rebuild after a disaster.

    • Click-ops creates snowflake environments, forgotten settings and no audit of why.
    • Drift is when reality no longer matches the code; what-if or terraform plan shows it.

    The trade-off: IaC costs learning time and discipline (no more "quick fixes" in the portal), but it is the only way to keep more than one environment consistent.

  2. When: Candidate recommends Bicep for an Azure-first team. Why: Checks the candidate can actually write the Bicep they recommend.
    How to answer

    I create a user-assigned managed identity first, then a Key Vault with enableRbacAuthorization: true, an Azure SQL server with Entra-only authentication (no SQL admin password), and a Container App that runs as that identity. Access is granted with Microsoft.Authorization/roleAssignments resources whose names are guid(scope, principalId, roleId), so redeployments are idempotent. The app receives AZURE_CLIENT_ID and a password-less connection string, and DefaultAzureCredential does the rest.

    • Environments differ only through .bicepparam files.
    • Every change is previewed with az deployment group what-if.

    The trade-off: Bicep handles the Azure control plane well, but it cannot create the SQL database user (a data-plane action), so a pipeline step runs CREATE USER ... FROM EXTERNAL PROVIDER.

  3. When: Candidate mentions a Terraform state backend or a pipeline service principal. Why: Checks how the IaC pipeline authenticates and protects state and secrets.
    How to answer

    My rule is to remove secrets rather than protect them. The pipeline authenticates to Azure with OIDC / workload identity federation: the CI platform issues a short-lived token that Entra trusts, so no client secret is stored. The app authenticates to SQL, Storage and Key Vault with managed identity. Remaining secrets (third-party API keys) live in Key Vault; the pipeline deploys only a Key Vault reference such as @Microsoft.KeyVault(VaultName=...;SecretName=...) as an app setting, and the platform resolves it with the app's identity, so the value never passes through the pipeline.

    Pipeline identities are least privilege: one per environment, roles on a resource group, protected by environment approvals. Secret scanning with push protection blocks committed secrets.

    If a secret leaks, I revoke and rotate first, then clean logs, then check access logs. The trade-off is up-front identity setup in exchange for nothing worth stealing in the pipeline.

🛠 Real-world problems: how you handle them

Choosing an IaC tool for a growing Azure platform
Situation
[Company] ran [around 30] .NET services on Azure in Australia East, with a mix of portal-created resources, old ARM JSON and one team's Terraform. A new platform team had to standardise before an ISO 27001 / Essential Eight audit in [timeframe].
Signals
Environments differed (SKUs, firewall rules); audit findings about undocumented changes; two Terraform states on engineers' laptops; ARM templates nobody would touch; Activity Log showing frequent manual portal edits in production.
Investigation
Inventoried resources with Azure Resource Graph (KQL) by resource group and tag; checked which were in any template; listed non-Azure resources teams also managed (GitHub repos, DNS in Cloudflare, Entra app registrations); ran what-if and terraform plan against prod to measure drift; reviewed the organisation's open-source licence policy with procurement.
Resolution
Immediate: moved the Terraform state into a locked, versioned storage account and removed humans' write access to prod. Long term: Bicep with deployment stacks for application resources in each service repo; OpenTofu for the platform layer (GitHub, DNS, landing zones) because the policy preferred OSI licences; legacy ARM decompiled to Bicep when touched.
Prevention
An ADR recording the split and reasons; shared modules from Azure Verified Modules; pipeline templates that always run what-if/plan and require approval for deletes; nightly drift check posting to Teams; Azure Policy denying public network access on data services.

How to tell it (STAR)

**S:** At [company] we had [about 30] services on Azure with three different ways of creating infrastructure and an audit coming in [timeframe]. **T:** I was asked to [lead / contribute to] choosing one approach without stopping delivery. **A:** I inventoried resources with Resource Graph, measured drift with what-if and plan, and listed what was outside Azure. That showed app teams only needed Azure, while the platform team also managed GitHub and DNS, so we chose Bicep with deployment stacks for services and [OpenTofu / Terraform] for the platform layer, wrote an ADR, and built one pipeline template with previews and approval on deletes. **R:** Within [a quarter], [X%] of production resources were in code, drift findings dropped from [N] to [near zero], and the audit closed the change-management finding.

More in Infrastructure as Code

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me