AZ-400 Design and implement build and release pipelines • Complete Question Bank
Complete AZ-400 Design and implement build and release pipelines question bank — all 0 questions with answers and detailed explanations.
Refer to the exhibit.
```json
{
"properties": {
"description": "Policy to require multiple reviewers for critical repos",
"policyType": "Build",
"mode": "Validation",
"initiative": "RequireMinimumReviewers",
"policyRule": {
"if": {
"field": "type",
"equals": "Microsoft.TeamFoundation/teamProjects"
},
"then": {
"effect": "audit",
"details": {
"minimumApproverCount": 2
}
}
}
}
}
```Drag steps to the numbered slots on the right, or tap a step then tap a slot.
Drag steps to the numbered slots on the right, or tap a step then tap a slot.
Drag a concept onto its matching description — or click a concept then click the description.
Compute resource to run jobs
Logical boundary for pipeline phases
Sequence of steps on a single agent
Atomic build or deployment action
Drag a concept onto its matching description — or click a concept then click the description.
Application performance monitoring and diagnostics
Query and analyze log data from various sources
Visualize performance metrics from Azure resources
Proactive notifications based on conditions
Refer to the exhibit.
```json
{
"policies": [
{
"policy": {
"name": "Require Pull Request Review",
"isEnabled": true,
"blocking": true,
"settings": {
"minimumApproverCount": 2,
"creatorVoteCounts": false,
"allowDownvotes": true,
"resetOnPush": false
}
}
}
]
}
```Refer to the exhibit.
```yaml
# azure-pipelines.yml
trigger:
branches:
include:
- main
- develop
stages:
- stage: Build
jobs:
- job: BuildJob
pool:
vmImage: ubuntu-latest
steps:
- script: echo "Building..."
- stage: Test
dependsOn: Build
condition: eq(variables['Build.SourceBranch'], 'refs/heads/develop')
jobs:
- job: TestJob
pool:
vmImage: ubuntu-latest
steps:
- script: echo "Testing..."
```Refer to the exhibit.
```bicep
resource appService 'Microsoft.Web/sites@2022-09-01' = {
name: 'myapp-${environment}'
location: resourceGroup().location
properties: {
serverFarmId: appServicePlan.id
siteConfig: {
appSettings: [
{
name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
value: appInsights.properties.InstrumentationKey
}
]
}
}
}
```Refer to the exhibit.
```json
{
"resources": {
"repositories": [
{
"repository": "shared-templates",
"type": "git",
"name": "myorg/shared-templates",
"ref": "refs/heads/main"
}
]
},
"jobs": [
{
"job": "build",
"steps": [
{
"checkout": "self"
},
{
"checkout": "shared-templates"
},
{
"template": "shared-templates/build-steps.yml",
"parameters": {
"buildConfiguration": "Release"
}
}
]
}
]
}
```Refer to the exhibit.
```yaml
# azure-pipelines.yml
trigger:
branches:
include:
- main
- release/*
pool:
vmImage: ubuntu-latest
variables:
- group: 'Prod-Environment'
stages:
- stage: Build
jobs:
- job: BuildJob
steps:
- script: echo Building...
- stage: Deploy
jobs:
- deployment: DeployToProd
environment: 'Production'
strategy:
runOnce:
deploy:
steps:
- script: echo Deploying...
```Refer to the exhibit.
```yaml
trigger:
branches:
include:
- main
- release/*
paths:
include:
- src/app/*
```Refer to the exhibit.
```yaml
- task: AzureKeyVault@2
inputs:
azureSubscription: 'MyServiceConnection'
KeyVaultName: 'mykv'
SecretsFilter: '*'
RunAsPreJob: false
```Refer to the exhibit. ```kusto ContainerLog | where TimeGenerated > ago(1h) | where LogEntry contains "Error" | project TimeGenerated, LogEntry, ContainerID ```
Refer to the exhibit.
```json
{
"triggers": [
{
"branch": "main",
"paths": {
"include": [
"/src/*"
]
}
}
],
"pool": {
"vmImage": "ubuntu-latest"
},
"steps": [
{
"script": "echo Building..."
}
]
}
```Refer to the exhibit.
```json
{
"variables": {
"buildConfiguration": "Release",
"publishEnabled": false
},
"stages": [
{
"stage": "Build",
"jobs": [
{
"job": "BuildJob",
"steps": [
{
"script": "echo Building..."
}
]
}
]
},
{
"stage": "Publish",
"dependsOn": "Build",
"condition": "eq(variables['publishEnabled'], true)",
"jobs": [
{
"job": "PublishJob",
"steps": [
{
"script": "echo Publishing..."
}
]
}
]
}
]
}
```Refer to the exhibit.
```json
{
"parameters": [
{
"name": "environment",
"values": ["dev", "test", "prod"]
}
],
"stages": [
{
"stage": "Deploy${{ parameters.environment }}",
"jobs": [
{
"job": "Deploy",
"steps": [
{
"task": "AzureWebApp@1",
"inputs": {
"appName": "myapp-${{ parameters.environment }}",
"package": "$(System.DefaultWorkingDirectory)/**/*.zip"
}
}
]
}
]
}
]
}
```Refer to the exhibit.
```yaml
# azure-pipelines.yml
trigger:
branches:
include:
- main
- develop
pr:
branches:
include:
- develop
```Refer to the exhibit.
```json
{
"name": "Deploy to AKS",
"type": "DeployPipeline",
"environment": "production",
"strategy": {
"runOnce": {
"deploy": {
"steps": [
{
"task": "Kubernetes@1",
"inputs": {
"kubernetesServiceConnection": "aks-prod",
"namespace": "prod",
"manifests": "$(Build.ArtifactStagingDirectory)/deployment.yaml"
}
}
]
}
}
},
"approvals": [
{
"approvers": [
"user@contoso.com"
]
}
]
}
```Refer to the exhibit.
```powershell
# Output from Azure CLI
{
"id": "/subscriptions/.../resourceGroups/rg-prod/providers/Microsoft.Web/sites/app-prod",
"kind": "app,linux",
"siteConfig": {
"linuxFxVersion": "DOTNETCORE|6.0",
"appSettings": [
{
"name": "ASPNETCORE_ENVIRONMENT",
"value": "Production"
}
]
}
}
```{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountName": {
"type": "string",
"defaultValue": "[uniqueString(resourceGroup().id)]"
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]"
}
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2022-09-01",
"name": "[parameters('storageAccountName')]",
"location": "[parameters('location')]",
"kind": "StorageV2",
"sku": {
"name": "Standard_LRS"
}
}
]
}{
"triggers": ["main"],
"pool": {
"vmImage": "ubuntu-latest"
},
"steps": [
{
"script": "echo Hello, world!"
}
]
}{
"parameters": {
"environment": {
"type": "string",
"defaultValue": "dev"
}
},
"variables": {
"resourceGroupName": "rg-$(environment)-001"
},
"trigger": "none",
"pool": {
"vmImage": "ubuntu-latest"
},
"stages": [
{
"stage": "Deploy",
"jobs": [
{
"job": "DeployJob",
"steps": [
{
"task": "AzureCLI@2",
"inputs": {
"azureSubscription": "MyServiceConnection",
"scriptType": "pscore",
"scriptLocation": "inlineScript",
"inlineScript": "az group create -n $(resourceGroupName) -l westus"
}
}
]
}
]
}
]
}Refer to the exhibit.
```json
{
"parameters": {
"environmentName": {
"type": "string",
"defaultValue": "dev"
},
"vmSku": {
"type": "string",
"defaultValue": "Standard_DS2_v2"
}
},
"variables": {
"vnetName": "[concat('vnet-', parameters('environmentName'))]"
},
"resources": [
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2023-11-01",
"name": "[variables('vnetName')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"10.0.0.0/16"
]
}
}
}
]
}
```Refer to the exhibit.
```bash
# Azure CLI output
{
"id": "/subscriptions/.../resourceGroups/rg-dev/providers/Microsoft.Web/sites/myapp-dev",
"name": "myapp-dev",
"type": "Microsoft.Web/sites",
"kind": "app",
"state": "Running"
}
```Refer to the exhibit.
```yaml
# GitHub Actions workflow snippet
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run tests
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "Running PR tests"
fi
```Refer to the exhibit. ```sql -- KQL query to get pipeline run duration let startTime = ago(7d); PipelineRuns | where RunStartTime >= startTime | summarize AvgDuration=avg(RunDurationSeconds) by PipelineName | where AvgDuration > 600 | project PipelineName, AvgDuration ```
Refer to the exhibit.
```yaml
jobs:
- deployment: Deploy
environment: prod
strategy:
runOnce:
deploy:
steps:
- download: current
artifact: drop
- task: AzureWebApp@1
inputs:
azureSubscription: 'myServiceConnection'
appName: 'myApp'
package: '$(Pipeline.Workspace)/drop/*.zip'
```Refer to the exhibit.
```json
{
"parameters": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appName": {
"value": "myapp"
},
"location": {
"value": "eastus"
},
"sku": {
"value": "S1"
}
}
}
}
```Refer to the exhibit.
```bicep
param location string = resourceGroup().location
param appName string
param containerImage string
resource appService 'Microsoft.Web/sites@2022-09-01' = {
name: appName
location: location
kind: 'app,linux'
properties: {
siteConfig: {
linuxFxVersion: 'DOCKER|${containerImage}'
appSettings: [
{
name: 'WEBSITES_ENABLE_APP_SERVICE_STORAGE'
value: 'false'
}
]
}
}
}
```Refer to the exhibit.
```yaml
# azure-pipelines.yml
variables:
- name: environment
value: 'dev'
stages:
- stage: Build
jobs:
- job: BuildJob
steps:
- script: echo "Building for $(environment)"
- stage: Deploy
dependsOn: Build
condition: succeeded()
variables:
environment: 'prod'
jobs:
- job: DeployJob
steps:
- script: echo "Deploying to $(environment)"
```Refer to the exhibit. You have the following YAML pipeline snippet:
```yaml
jobs:
- job: Build
steps:
- task: DotNetCoreCLI@2
inputs:
command: 'build'
projects: '**/*.csproj'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
```Refer to the exhibit. You have the following Azure Key Vault secret reference in your pipeline: ```yaml variables: - group: my-variable-group - name: mySecret value: $(myKeyVaultSecret) ``` And the variable group is linked to an Azure Key Vault. The pipeline fails with the error 'Secret myKeyVaultSecret not found'.
Refer to the exhibit.
```yaml
# azure-pipelines.yml
trigger:
branches:
include:
- main
- release/*
paths:
exclude:
- docs/*
```Refer to the exhibit.
```json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]"
},
"vmName": {
"type": "string"
}
},
"resources": [
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2021-03-01",
"name": "[parameters('vmName')]",
"location": "[parameters('location')]",
"properties": {
"hardwareProfile": {
"vmSize": "Standard_DS2_v2"
},
"osProfile": {
"computerName": "[parameters('vmName')]",
"adminUsername": "azureuser",
"adminPassword": "P@ssw0rd123!"
}
}
}
]
}
```{
"variables": {
"buildConfiguration": "Release",
"majorVersion": 1,
"minorVersion": 0,
"revision": $[counter(variables['minorVersion'], 0)]
},
"steps": [
{
"script": "echo $(Build.BuildNumber)"
}
]
}```json
{
"resources": {
"repositories": [
{
"repository": "myrepo",
"type": "git",
"name": "MyProject/myrepo",
"ref": "refs/tags/v1.0"
}
]
},
"trigger":
[
"main"
]
}``````
variables:
- group: ReleaseVariables
- name: EnvironmentName
value: Production
stages:
- stage: Deploy
jobs:
- deployment: DeployWeb
environment:
name: $(EnvironmentName)
resourceType: VirtualMachine
```{
"steps": [
{
"task": "DotNetCoreCLI@2",
"inputs": {
"command": "publish",
"publishWebProjects": true,
"zipAfterPublish": true
}
},
{
"task": "AzureWebApp@1",
"inputs": {
"azureSubscription": "MyServiceConnection",
"appType": "webApp",
"appName": "myapp",
"package": "$(System.DefaultWorkingDirectory)/**/*.zip"
}
}
]
}{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Web/sites/config",
"apiVersion": "2021-02-01",
"name": "[concat(parameters('siteName'), '/appsettings')]",
"properties": {
"APPINSIGHTS_INSTRUMENTATIONKEY": "[reference(resourceId('Microsoft.Insights/components', parameters('insightsName')), '2020-02-02').InstrumentationKey]"
}
}
]
}You are a DevOps engineer at a large enterprise that develops a cloud-native application using microservices architecture. The application consists of 15 microservices, each stored in a separate GitHub repository. Your team uses GitHub Actions for CI/CD and Azure Kubernetes Service (AKS) for production. The current deployment process is manual and error-prone. You need to design an automated CI/CD pipeline that supports the following requirements:
1. Each microservice must have its own build and test pipeline triggered on pull requests and merges to the main branch. 2. Upon merging to main, a container image must be built, tagged with the Git commit SHA, and pushed to Azure Container Registry (ACR). 3. A separate release pipeline must deploy the updated images to AKS using a GitOps approach with Flux v2. 4. The release pipeline must support rolling back to a previous version quickly if a deployment fails. 5. The entire solution must be defined as code to ensure reproducibility.
Which approach should you recommend?
{
"triggers": ["master", "develop"],
"phases": [
{
"phase": "Build",
"steps": [
{
"task": "DotNetCoreCLI@2",
"inputs": {
"command": "build",
"projects": "**/*.csproj"
}
}
]
},
{
"phase": "Test",
"steps": [
{
"task": "VSTest@2",
"inputs": {
"testSelector": "testAssemblies",
"testAssemblyVer2": "**\\*test*.dll",
"searchFolder": "$(System.DefaultWorkingDirectory)"
}
}
]
}
]
}resources:
repositories:
- repository: internal
type: git
name: MyProject/MyRepo
ref: refs/heads/main
trigger:
branches:
include:
- main
- release/*
pool:
vmImage: 'ubuntu-latest'
steps:
- checkout: self
- checkout: internal
- script: echo "Building..."{
"triggers": [
{
"branchFilters": ["main", "develop"],
"paths": {
"include": ["/src/*"],
"exclude": ["/src/tests/*"]
},
"batchChanges": true,
"maxConcurrentBuildsPerBranch": 1,
"triggerType": "continuousIntegration"
}
]
}