AZ-400 Infrastructure as Code 2 — Questions and Answers
Question 1: In Azure Bicep, what is the purpose of the `@description` decorator?
- Marks a parameter as required
- Adds human-readable documentation to parameters and outputs (Correct answer)
- Specifies the default value for a parameter
- Restricts allowed values for a parameter
Correct answer: Adds human-readable documentation to parameters and outputs
The `@description` decorator adds metadata documentation strings to parameters, variables, and outputs in Bicep files.
Question 2: Which Terraform command is used to preview infrastructure changes without applying them?
- terraform validate
- terraform apply --dry-run
- terraform plan (Correct answer)
- terraform refresh
Correct answer: terraform plan
`terraform plan` generates an execution plan showing what changes Terraform will make without actually applying them.
Question 3: When using Azure Resource Manager (ARM) templates, what does the `dependsOn` property control?
- The order of template parameter evaluation
- Explicit resource deployment ordering when implicit dependencies are insufficient (Correct answer)
- The version of the ARM API to use
- Which resource group the resource deploys into
Correct answer: Explicit resource deployment ordering when implicit dependencies are insufficient
`dependsOn` explicitly defines deployment dependencies so ARM waits for specified resources to finish before deploying the dependent resource.
Question 4: What is the primary benefit of using Terraform workspaces in a multi-environment IaC strategy?
- They allow multiple teams to edit the same state file simultaneously
- They enable managing multiple distinct state files from the same configuration (Correct answer)
- They encrypt the Terraform state file at rest
- They automatically create Azure resource groups per environment
Correct answer: They enable managing multiple distinct state files from the same configuration
Terraform workspaces maintain separate state files for each workspace, letting the same configuration manage dev, staging, and prod environments independently.
Question 5: In Azure DevOps pipelines, which built-in variable contains the source branch name that triggered the pipeline?
- $(Build.SourceBranchName) (Correct answer)
- $(System.PullRequest.TargetBranch)
- $(Agent.BuildDirectory)
- $(Pipeline.Workspace)
Correct answer: $(Build.SourceBranchName)
`$(Build.SourceBranchName)` contains the branch or tag name (without refs/heads/) that triggered the current pipeline run.
Question 6: What does the `terraform taint` command (or its modern equivalent `terraform apply -replace`) do?
- Marks a resource as corrupted so it will be destroyed and recreated on next apply (Correct answer)
- Locks the state file to prevent concurrent modifications
- Validates that all resource configurations are syntactically correct
- Removes a resource from Terraform management without destroying it
Correct answer: Marks a resource as corrupted so it will be destroyed and recreated on next apply
Tainting (or `-replace`) marks a specific resource for destruction and recreation on the next `terraform apply`, useful when a resource is in a broken state.
Question 7: Which Azure Bicep feature allows you to deploy the same resource configuration to multiple instances using a single declaration?
- modules
- decorators
- resource loops using `for` expressions (Correct answer)
- conditional deployments using `if`
Correct answer: resource loops using `for` expressions
Bicep supports `for` loops in resource declarations to create multiple instances of a resource from an array or range without repeating code.
In Azure Bicep, what is the purpose of the `@description` decorator?