AZ-400 Continuous Integration 4 — Questions and Answers
Question 1: What is the purpose of 'code coverage' metrics collected during a CI pipeline?
- To measure the number of lines of code committed per sprint
- To report what percentage of source code is exercised by automated tests (Correct answer)
- To track how many developers contributed to a build
- To count the number of code review comments per pull request
Correct answer: To report what percentage of source code is exercised by automated tests
Code coverage metrics indicate the proportion of production code executed by automated tests, helping teams identify untested code paths.
Question 2: A pipeline needs to pass a secret API key to a build script securely. What is the correct approach in Azure Pipelines?
- Store the key in a YAML variable in plain text
- Store the key as a secret pipeline variable and reference it with $(VariableName) (Correct answer)
- Encode the key in Base64 and place it in the pipeline YAML
- Pass the key as a command-line argument in the trigger configuration
Correct answer: Store the key as a secret pipeline variable and reference it with $(VariableName)
Secret pipeline variables are masked in logs and encrypted at rest; they are referenced the same way as regular variables but never exposed in output.
Question 3: Which Azure DevOps feature allows you to group related pipelines and share variables, service connections, and agent pools across them?
- Pipeline environments
- Pipeline libraries and variable groups (Correct answer)
- Deployment groups
- Agent pool permissions
Correct answer: Pipeline libraries and variable groups
Variable groups in the Pipelines Library let you define shared variables and link Azure Key Vault secrets that can be referenced by multiple pipelines.
Question 4: What does 'shift-left testing' mean in the context of a CI/CD pipeline?
- Running production deployments before staging validations
- Performing tests earlier in the development lifecycle, closer to code authoring (Correct answer)
- Moving test execution to a left-side agent pool
- Prioritizing UI tests over unit tests in the pipeline
Correct answer: Performing tests earlier in the development lifecycle, closer to code authoring
Shift-left testing moves quality checks (unit tests, static analysis, security scans) earlier in the pipeline so defects are caught before later, more expensive stages.
Question 5: In Azure Pipelines, which condition expression causes a step to run only when the previous step fails?
- condition: always()
- condition: failed() (Correct answer)
- condition: succeededOrFailed()
- condition: canceled()
Correct answer: condition: failed()
The failed() condition expression makes a step execute only when one or more preceding steps have failed, useful for cleanup or notification steps.
Question 6: A team wants to block merges to 'main' unless two approvers have reviewed the PR AND the CI build passes. Which combination of Azure DevOps branch policies achieves this?
- Minimum reviewer count policy + build validation policy (Correct answer)
- Commit message validation + work item linking policy
- Branch lock + merge strategy policy
- Status check policy + comment resolution policy
Correct answer: Minimum reviewer count policy + build validation policy
Combining the minimum number of reviewers policy with the build validation policy enforces both human approval and automated build success as merge prerequisites.
Question 7: What is the benefit of using 'pipeline artifacts' (PublishPipelineArtifact) over 'build artifacts' (PublishBuildArtifacts) in Azure Pipelines?
- Pipeline artifacts support larger file sizes with no limits
- Pipeline artifacts use Azure Blob Storage and are faster to upload and download (Correct answer)
- Pipeline artifacts are automatically deployed to Azure App Service
- Pipeline artifacts persist indefinitely without retention policies
Correct answer: Pipeline artifacts use Azure Blob Storage and are faster to upload and download
PublishPipelineArtifact leverages Azure Blob Storage with optimized chunked transfers, providing significantly faster upload and download speeds than the legacy build artifact mechanism.
What is the purpose of 'code coverage' metrics collected during a CI pipeline?