🚀 Get Started With Infrastructure-as-Code (IaC)
By Anatoly Mironov
Infrastructure-as-Code (IaC) is a widely admired principle among many professionals I meet. Yet, getting started with IaC can feel daunting—especially when working with legacy systems or under tight deadlines.
This post offers a simple, step-by-step demo to help you ease into IaC. Even partial adoption is better than none, and I’ll show you how to get started without overcomplicating things.
đź§Ş Demo Setup
Here’s the environment I’m using:
- One Azure Subscription (for simplicity)
- Azure DevOps Project
- One Azure Service Connection with Contributor access at the subscription level
- Azure Pipelines
- Azure CLI
- Bicep
- Azure Deployment Stacks
Yes, it’s very Azure-heavy—but the same principles apply to GitHub, GitLab, or other platforms.
NOTE: I assume you already have a service connection set up.
To make this guide as digestable as possible, I am assuming you already have a service connection set up.
Here is a simplified diagram of the target demo setup.

đź”§ Step 1: Create a New Pipeline
In your Azure DevOps project:
- Go to Pipelines and create a new one.
- Choose Azure Pipelines and leave the default settings.
- Click Save and Run.

It’s simple, yet powerful—there’s a lot happening behind the scenes to get your pipeline running.

🏗️ Step 2: Add Bicep and a Deployment Stack
Create a file infra/main.bicep with the following code to create a resource group:
Now update your azure-pipelines.yml to deploy this Bicep file using Azure CLI:
After committing and pushing, a new resource group should be created—success!

Tip: If your pipeline gets stuck, try running the Azure CLI commands locally to debug.
az stack sub create \
--template-file ./infra/main.bicep \
--name iac-demo-002 \
--location westeurope \
--action-on-unmanage deleteResources \
--deny-settings-mode None
🌱 Step 3: Add Your First Environment – DEV
Let’s introduce environments: DEV, TEST, and PROD.
The environments will be automatically created when you refer to them in the pipeline.
Update your pipeline to include stages and a checkout step:

đź§© Step 4: Restructure with Templates
To follow the DRY (Don’t Repeat Yourself) principle, move the repeated stage logic into a template file:
pipelines/templates/deploy.yml:
With a template file, the main azure-pipelines.yml becomes lighter:
Commit and push your changes to Azure DevOps and see that it works.
đź§Ş Step 5: Parameterize Bicep
Now one step before we can add TEST and PROD is making sure everything is parameterized.
Add an environment parameter to infra/main.bicep:
Create a parameter file for DEV: infra/parameters/DEV.bicepparam:
Update the template to include parameters in pipelines/templates/deploy.yml:
--parameters ./infra/parameters/${{ parameters.environment }}.bicepparam
Try this out by pushing the changes to Azure DevOps.
đź§Ş Step 6: Add TEST and PROD
Now that we have parameterized everything, adding the TEST and PROD environments is really really simple.
Create two more parameter files:
infra/parameters/TEST.bicepparam:
infra/parameters/PROD.bicepparam:
Then add two more stages to your pipeline in azure-pipelines.yml:

Further steps
Althought not in scope, but consider taking it further. Try to:
- Set up Approvals for environments
- Add resources to the IaC
- Deploy the apps (CI/CD)
đź§Ľ Cleanup
Since we’re using Deployment Stacks, cleanup is easy:
Summary
This guide walks you through setting up IaC with Azure DevOps using Bicep and Deployment Stacks. Even a minimal setup can make a big difference. From here, consider adding:
- Environment approvals
- More resources
- CI/CD for app deployment