Microsoft Azure Learning Journey

Stop Clicking: Declare Azure Infrastructure with Bicep

Describe the Azure resources you want, preview the change, and let Azure Resource Manager converge the deployment.

6 min read · 1176 words
Microsoft AzureInfrastructure as CodeTerraformBicepDevOps
Stop Clicking: Declare Azure Infrastructure with Bicep cover image

A portal deployment is easy to understand once and hard to reproduce six months later. A template checked into source control records the desired configuration, enables review, and makes repeated deployments predictable. Bicep is Azure’s concise language for authoring Azure Resource Manager (ARM) deployments.

What you’ll learn

Where this fits

Module 23, Phase 6, Part 1. Phase 5 covered data services; now we make infrastructure repeatable. Next: Terraform on Azure.

Prerequisites

ARM and Bicep in plain English

Azure Resource Manager (ARM) is the control plane that receives authenticated requests, validates them, and coordinates Azure resource providers. Bicep is a domain-specific language that compiles to ARM JSON; it does not replace ARM or run a separate deployment engine.

With declarative infrastructure, you describe the intended resources rather than a sequence of imperative creation steps. ARM calculates dependencies and applies the deployment. Reapply the same template and parameters to reconcile Azure with the declared desired state. A template does not make every provider operation idempotent or reversible—review API behavior and change plans.

A resource declaration is not the whole design

A useful Bicep project has:

Deployment scope determines which resource types the file can create directly. A resource-group deployment targets resources in an existing group; subscription-scope deployments can create resource groups and coordinate their deployments. Management-group and tenant scopes support broader governance deployments and require correspondingly broader permissions.

Dependencies and deployment order

Bicep infers dependencies when one resource refers to another resource’s properties. Use dependsOn only when there is a real dependency that the expression does not already express. Excessive explicit dependencies serialize work and obscure the graph. Circular dependencies should be fixed in the architecture, not hidden by changing deployment order.

Modules can target other scopes and can be sourced from local files, template specs, or a Bicep registry. Pin and review shared modules; a remote module update can change every environment that consumes it.

Hands-on: compile and preview a storage account

This exercise writes a small template, compiles it, and previews it against an existing resource group. what-if does not apply the proposed change; do not run az deployment group create unless you intend to deploy and pay for the account.

@description('Globally unique lowercase name, 3-24 characters.')
@minLength(3)
@maxLength(24)
param storageName string

param location string = resourceGroup().location

resource storage 'Microsoft.Storage/storageAccounts@2023-05-01' = {
  name: storageName
  location: location
  kind: 'StorageV2'
  sku: {
    name: 'Standard_LRS'
  }
  properties: {
    accessTier: 'Hot'
    allowBlobPublicAccess: false
    minimumTlsVersion: 'TLS1_2'
    supportsHttpsTrafficOnly: true
  }
}

output storageResourceId string = storage.id

Save it as storage.bicep, then compile and preview:

az login
az account set --subscription "<YOUR_DEVELOPMENT_SUBSCRIPTION_ID_OR_NAME>"
RESOURCE_GROUP="<EXISTING_DEVELOPMENT_RESOURCE_GROUP>"
STORAGE_NAME="<UNIQUE_LOWERCASE_NAME>"

az bicep build --file storage.bicep --stdout > /dev/null
az deployment group what-if --resource-group "$RESOURCE_GROUP" \
  --template-file storage.bicep \
  --parameters storageName="$STORAGE_NAME"

The preview should report a proposed Storage account creation and show the access configuration. If the account name is already in use, choose a new globally unique name. The template creates nothing until a deployment operation is explicitly submitted.

✅ Checkpoint: Bicep compiles without diagnostics, and the preview shows only the intended storage account with public blob access disabled.

Identity, secret handling, and cost

The person or pipeline submitting a deployment authenticates through Microsoft Entra ID. Azure RBAC authorizes ARM operations at the subscription, resource-group, or resource scope. The identity used by the deployed workload is separate; give that workload a managed identity and data-plane roles rather than embedding deployment credentials in Bicep.

Avoid secrets in source files, command-line arguments, parameter files, and outputs. A secure Bicep parameter reduces display in some deployment surfaces but does not make a secret safe to commit or expose to an overprivileged deployer. Prefer Key Vault references or managed identity for runtime secret retrieval. ARM deployment history and stateful systems still need access controls.

what-if and compilation create no resources. Applying a template can create billable resources; review SKUs, region, networking, data retention, and logging. Use the Azure Pricing Calculator for estimates—budgets and alerts notify, but do not cap spending.

Troubleshooting

Five-pillar readiness checklist

Cleanup

No Azure resources were created by the exercise. No cleanup is needed. If you separately applied the template, delete only the lab-owned resource through the normal ARM lifecycle after verifying no other deployment depends on it.

Key takeaways

Next: Terraform on Azure: State, Identity, and Repeatable Deployments.

Series navigation: Previous: Cosmos DB and Caching · Current: Phase 6, Part 1 · Next: Terraform

References

Share this article

LinkedIn post draft