Microsoft Azure's equivalent to AWS CloudFormation is ARM templates (Azure Resource Manager templates), and the modern, easier-to-write option is Bicep. Both describe your Azure infrastructure in a file, and you deploy that file to Azure Resource Manager, which creates or updates everything in a single, repeatable operation. In short: write a Bicep or JSON template, deploy it with the Azure CLI, PowerShell, or the portal's "Deploy a custom template" experience, and Azure handles ordering and dependencies for you.

A few terms to map first. CloudFormation has stacks, templates, parameters, outputs and change sets. Azure has resource groups, templates, parameters, outputs and what-if previews. A CloudFormation stack is closest to a deployment inside a resource group or subscription. Azure also supports Terraform, if you prefer a cloud-neutral tool, but ARM and Bicep are the native answers.

What You'll Need

  • An Azure subscription with permission to create resources in the target scope (at minimum Contributor on the resource group or subscription you will deploy to).
  • The Azure CLI or Azure PowerShell installed locally, or access to Azure Cloud Shell in the portal, which has both already set up.
  • The Bicep CLI for authoring and compiling Bicep. Recent Azure CLI versions include Bicep, so az bicep install is usually enough.
  • A code editor with the Bicep extension for syntax checking and IntelliSense; Visual Studio Code with the official Bicep extension is the common choice.
  • A resource group to deploy into, or permission to create one.

Step-by-Step

  1. Sign in and select your subscription. Run az login, then az account set --subscription "<name-or-id>". Confirm with az account show. Getting the wrong subscription here is the single most common cause of "it deployed to the wrong place" confusion.
  2. Create or choose a resource group. Use az group create --name my-rg --location westeurope. Resource groups are the natural boundary for most deployments and make cleanup trivial: deleting the group removes everything inside it.
  3. Scaffold your first template. Create a file called main.bicep. A minimal starting point declares a storage account:
    param location string = resourceGroup().location
    param name string = 'stexample001'
    
    resource sa 'Microsoft.Storage/storageAccounts@2023-01-01' = {
      name: name
      location: location
      sku: { name: 'Standard_LRS' }
      kind: 'StorageV2'
    }
    If you prefer raw JSON, CloudFormation-style authoring also allows ARM templates, but Bicep compiles down to JSON and is far less verbose. Microsoft's template reference documents every resource type and API version.
  4. Add parameters and outputs. Parameters make the same template reusable across environments; outputs expose values like connection strings or resource IDs to scripts and other templates. Give parameters types and sensible defaults, and avoid hardcoding secrets. For sensitive values use @secure() parameters, or better, reference a key vault.
  5. Preview the change. Run az deployment group what-if --resource-group my-rg --template-file main.bicep. What-if lists what will be created, modified or deleted. This is Azure's answer to a CloudFormation change set, and it is the step people skip most often.
  6. Deploy. Run az deployment group create --resource-group my-rg --template-file main.bicep --parameters name=stexample002. Azure Resource Manager works out dependency order, so you rarely need to declare it manually in Bicep.
  7. Verify. Check az deployment group show --resource-group my-rg --name main for the provisioning result and outputs, and confirm resources in the portal. Each deployment leaves a history you can inspect.
  8. Put it under version control and add automation. Commit templates to a Git repository. For repeatable releases, deploy the same file from a pipeline (Azure Pipelines, GitHub Actions) rather than by hand, so every environment gets identical infrastructure.

Menu and command labels can differ slightly by CLI version, region and portal revision, so treat the paths above as a guide rather than gospel. The portal route is search for "Deploy a custom template" and build or upload your template in the editor; it is useful for one-off tests but not for ongoing work.

Common Mistakes

  • Skipping what-if. Deploying blind can delete or replace resources when a property changes in a non-additive way. Always preview first.
  • Hardcoding secrets and locations. Secrets in templates leak into source control and deployment history. Use secure parameters, key vault references, or a secret store in your pipeline. Use parameters for location so the same template works in any region.
  • Choosing the wrong deployment scope. Resource-group deployments cannot create subscription-level resources such as policy assignments. Use subscription scope for those, and know which one you are running.
  • Assuming redeployment resets everything. ARM is declarative but incremental by default: it adds and updates, but does not remove resources absent from the template. Deletion of orphans requires a complete-mode deployment, which is destructive.
  • Ignoring API versions. Pinning an outdated resource API version can silently drop newer properties. Check the template reference for the current version of the resource type you are using.

Tips

  • Break large templates into modules in Bicep, or nested templates in raw ARM, and compose them in a parent file. This mirrors CloudFormation nested stacks and keeps files readable.
  • Use existing resource declarations in Bicep to reference resources you did not create in this deployment, rather than redeclaring them.
  • Tag everything with parameters for owner, environment and cost centre; tags make cost reporting and cleanup far easier.
  • Store environment-specific values in separate parameter files and pass them at deploy time, instead of branching inside the template.
  • Lint as you go. az bicep build catches syntax errors before deployment, and the Bicep extension flags many problems in the editor.

Troubleshooting

When a deployment fails, read the error from the bottom up: the innermost resource error is usually the real cause, and outer messages are just wrappers. Run az deployment group show with the operation details, or open the deployment in the portal's Deployments blade, to see which resource failed and why.

  • Authorization failed: your signed-in identity lacks permission at the deployment scope. Check the subscription and role assignment.
  • Resource name already taken: names for some types, such as storage accounts, are globally unique. Change the name or add a unique suffix with a function.
  • Quota or region restriction: the subscription may not offer the resource in that region or may have hit a quota. Try another region or request a quota increase.
  • Template validation error: check the resource API version and property names against the current template reference; a single misspelled property fails validation before anything is deployed.
  • Partial failure: a failed deployment leaves successfully created resources in place. Fix the template, redeploy, then verify with what-if that nothing unintended is scheduled.

Frequently Asked Questions

Is Bicep the same as CloudFormation?

Functionally similar: both are declarative infrastructure-as-code tools native to their cloud. Bicep is Azure-specific and compiles to ARM JSON.

Can I migrate an existing CloudFormation template directly?

Not automatically. The resource models differ, so you translate resources by hand or use a third-party conversion tool, then validate heavily with what-if.

Should I use Terraform instead?

Terraform works well across clouds and is officially supported for Azure. Choose it if you manage multiple clouds; choose Bicep if you want the simplest native path with day-one support for new Azure features.

How do I delete everything a template created?

Deleting the resource group removes all resources in it. For finer control, use a complete-mode deployment, but that deletes anything in scope not present in the template, so preview carefully first.

Does deployment history cost anything?

Deployment records are retained by Azure with limits that vary by scope; old records may need pruning. Check current limits in the documentation.