Launch price: every exam for $29.99 a year, for the first 300 buyers. See the price

CertStreak
Menu

Specify continuous integration and continuous deployment (CI/CD) requirements for integration and release, including infrastructure-as-code deployments and testing

A worked example

Complete the statement

Fabrikam deploys its agent infrastructure with one Bicep file, infrastructure/main.bicep, for all environments. The exhibit shows an excerpt of the file.

You are writing the production deployment job. Requirements:

  • Designated reviewers must approve before the production deployment steps run. A repository administrator has already added these reviewers in the GitHub repository settings, under the environment named production.
  • The job must deploy the template into the existing resource group fabrikam-agents-production.
  • The template must apply its production values for model, compute, and scaling.
// Excerpt of infrastructure/main.bicep
@description('Environment name: dev, staging, or production')
@allowed(['dev', 'staging', 'production'])
param environment string

@description('Azure region for deployment')
param location string = resourceGroup().location

@description('Agent name')
param agentName string

Complete the job so that it meets all the requirements.

jobs:
  deploy-production:
    runs-on: ubuntu-latest
    : production
    steps:
      - uses: actions/checkout@v4
      - name: Azure Login
        uses: azure/login@v1
        with:
          creds: $
      - name: Deploy agent infrastructure
        run: |
          az deployment  create \
            --resource-group fabrikam-agents-production \
            --template-file infrastructure/main.bicep \
            --parameters environment= agentName=orchestrator
  • Blank 1: environment (correct answer)

    Declaring environment: production binds the job to the protected GitHub environment. GitHub then pauses at that declaration and notifies the required reviewers. needs names prerequisite jobs, not an approval gate. concurrency groups runs to limit parallel execution. permissions sets GITHUB_TOKEN scopes and does not accept an environment name. None of these three makes the job wait for reviewer approval.

  • Blank 2: group (correct answer)

    The requirement is to deploy into an existing resource group. The command passes --resource-group, and the template reads resourceGroup().location, so it is a resource-group-scope deployment: az deployment group create. sub, mg, and tenant deploy at subscription, management group, and tenant scope. Those commands do not target a resource group with --resource-group.

  • Blank 3: production (correct answer)

    The template's allowed values are dev, staging, and production, and the job must apply production settings, so the value is production. dev and staging are valid values but would deploy the smaller non-production configuration. prod is not in the @allowed list, so the deployment would be rejected.

Why

The approval gate comes from a GitHub environment protection rule. The reviewers are already configured on the production environment, so the job only needs to declare environment: production. GitHub then pauses the job until a reviewer approves. The infrastructure is deployed as code by running one Bicep template at resource-group scope with az deployment group create. The environment parameter, restricted to dev, staging, or production, selects the production-specific model, compute, and scaling values.

Practise this topic until it's automatic.

Ten questions a day, every answer explained, and misses that come back until you beat them.

Start free