Infrastructure as code and configuration
Configuration management tools, an IaC strategy with testing and automation, desired state configuration, and Azure Deployment Environments.
In this lesson you'll learn
- Recommending configuration management technology
- An IaC strategy: source control, testing and automation
- Desired state with ARM, Bicep, Machine Configuration and Automation State Configuration
- Azure Deployment Environments for self-service
1. Infrastructure as code versus configuration management
Infrastructure as code (IaC) creates and changes resources: ARM templates, Bicep, Terraform, Pulumi. Configuration management sets up what's inside machines: packages, files, services. Tools include Ansible (agentless, over SSH or WinRM), Chef and Puppet (agents), PowerShell DSC and Azure Machine Configuration.
Recommend by need: Bicep for Azure-only teams who want first-party support and no state file; Terraform for many clouds or providers; Ansible for agentless configuration across mixed servers; Machine Configuration for auditing and enforcing settings at scale through Azure Policy.
2. An IaC strategy
- Source control: infrastructure code in Git, changed only through pull requests.
- Testing: linting (
bicep lint,terraform validate), what-if or plan in the pull request so reviewers see the effect, policy checks, and deployment to a test environment. - Automation: pipelines deploy; nobody changes production by hand. Drift detection (scheduled what-if or plan) finds hand changes.
- Idempotence: deploying the same code twice gives the same result.
3. Desired state configuration
Desired state means declaring what should be true, and a tool checks and corrects it.
- Azure Resource Manager and Bicep: declarative for Azure resources; complete mode removes resources not in the template (use with care).
- Azure Machine Configuration (formerly guest configuration): audits or applies settings inside Windows and Linux machines, including Arc-enabled servers, assigned through Azure Policy.
- Azure Automation State Configuration: the older DSC pull service; it's being retired, with Machine Configuration as the replacement.
4. Azure Deployment Environments
Azure Deployment Environments let developers create environments themselves from approved templates. Platform engineers set up a dev center with catalogs (template repositories, ARM, Bicep or Terraform), environment types (dev, test) mapped to subscriptions, and permissions. Developers then create and delete environments on demand, within the guard rails, from the portal, CLI or pipelines.
Example
Harbourline Design's developers used to wait a week for a test environment. Now they pick "Web app with SQL" from the Deployment Environments catalog and have their own copy in 10 minutes, created in the test subscription with tags, cost limits and policies already applied.
Exam traps to remember
- What-if (Bicep) and plan (Terraform) are the review step for IaC changes.
- Machine Configuration replaces Automation State Configuration for in-guest settings.
- Deployment Environments give developers self-service within platform-defined templates.
Test yourself: 3 check questions and exam-style practice questions on this topic are in the AZ-400 DevOps Engineer app.
Practise in the app