You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Infrastructure as Code (IaC) is the practice of managing and provisioning cloud resources through machine-readable configuration files rather than manual processes such as clicking through the Azure Portal. On Azure, IaC enables you to define virtual machines, networks, databases, and every other resource in a declarative or imperative format that can be version-controlled, reviewed, tested, and reused.
Imagine you need to deploy a web application to Azure. You open the Azure Portal, create a resource group, provision an App Service Plan, deploy a Web App, configure a SQL Database, set up networking rules, and wire everything together. It works — but then you need to do it again for staging, and again for production, and again in a second region.
Manual provisioning leads to:
With IaC, you describe your infrastructure in files. Those files become the single source of truth:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2023-01-01",
"name": "mystorageaccount",
"location": "[resourceGroup().location]",
"sku": { "name": "Standard_LRS" },
"kind": "StorageV2"
}
]
}
This JSON file is an ARM template — Azure's native IaC format. It declares a storage account. You can deploy it with a single command, store it in Git, and reproduce the exact same resource every time.
| Approach | You describe... | Azure examples |
|---|---|---|
| Declarative | The desired end state | ARM templates, Bicep, Terraform |
| Imperative | The exact steps to execute | Azure CLI scripts, Azure PowerShell scripts |
resource storageAccount 'Microsoft.Storage/storageAccounts@2023-01-01' = {
name: 'mystorageaccount'
location: resourceGroup().location
sku: { name: 'Standard_LRS' }
kind: 'StorageV2'
}
You state what you want. Azure Resource Manager figures out how to create or update it.
az storage account create \
--name mystorageaccount \
--resource-group myResourceGroup \
--location uksouth \
--sku Standard_LRS \
--kind StorageV2
You tell Azure the exact command to run. If the storage account already exists, you may need additional logic to handle updates.
Best practice: Prefer declarative IaC for production infrastructure. Imperative scripts are useful for one-off tasks and automation glue.
Azure supports a rich ecosystem of IaC tools:
| Tool | Type | Language | Maintained by |
|---|---|---|---|
| ARM templates | Declarative | JSON | Microsoft |
| Bicep | Declarative | Bicep DSL | Microsoft |
| Terraform | Declarative | HCL | HashiCorp |
| Pulumi | Declarative | TypeScript, Python, Go, C# | Pulumi |
| Azure CLI | Imperative | Bash | Microsoft |
| Azure PowerShell | Imperative | PowerShell | Microsoft |
| Ansible | Imperative/Declarative | YAML | Red Hat |
In this course, we focus on ARM templates, Bicep, and Terraform on Azure — the three most widely used declarative IaC tools in the Azure ecosystem.
Deploy the same template to dev, staging, and production with identical configurations.
Store templates in Git. Review changes through pull requests. Roll back to a previous version if something breaks.
Integrate deployments into CI/CD pipelines using Azure DevOps, GitHub Actions, or any other CI system.
Use Azure Policy and template validation to enforce organisational standards before resources are created.
Define resource SKUs, sizes, and auto-scaling rules in code. Destroy entire environments when they are no longer needed.
If a region fails, redeploy the same templates to another region within minutes.
All IaC tools on Azure ultimately interact with Azure Resource Manager (ARM) — the deployment and management service that processes API requests. Whether you use the Azure Portal, Azure CLI, Bicep, or Terraform, every operation passes through ARM.
User / Tool → ARM API → Resource Provider → Azure Resource
ARM provides:
Infrastructure as Code transforms Azure resource management from a manual, error-prone process into a repeatable, version-controlled, and automated discipline. Azure supports multiple IaC tools — ARM templates, Bicep, Terraform, and more — all of which interact with Azure Resource Manager. In the following lessons, we will explore ARM in detail, learn template syntax, and progress to Bicep and Terraform on Azure.