Lesson 4 of 4 Deploying Multi-Agent Solutions

Specifying CI/CD Pipelines and Infrastructure as Code

This lesson specifies the CI/CD requirements, including infrastructure as code and testing, that make every change to a multi-agent solution follow the same automated, tested and audited path.

Learning outcomes

After completing this lesson, you will be able to:

  • Define Azure resources with Bicep or Terraform.
  • Describe the stages of a pipeline for agent solutions.
  • Authenticate pipelines with workload identity federation.

Infrastructure as code

Infrastructure as code (IaC) defines Azure resources in templates: Bicep (Azure's declarative language) or Terraform. Templates create the Foundry resource and project, model deployments, AI Search, Cosmos DB, Key Vault, Container Apps, API Management, networking, identities and role assignments. The Azure Developer CLI (azd) combines IaC with application deployment through an azure.yaml project file, so azd provision creates resources and azd deploy deploys services and agents. Templates are validated in CI with linting, az bicep build and a what-if preview that shows changes before they are applied.

Match the pairs

IaC and azd commands

Exam skills 4.3.4

Match each tool or command with what it does.

Log in to try this activity Interactive activities are free with an account.

Pipeline stages

A typical pipeline in GitHub Actions or Azure Pipelines has the stages listed below.

  • Pull request (CI): lint, unit tests, secret and dependency scanning, IaC validation and what-if, fast evaluation on a small dataset.
  • Build: build and scan container images; package agent definitions and prompts as artefacts.
  • Deploy to test: provision or update infrastructure, deploy services and agents, run integration tests.
  • Evaluate: full regression evaluation and red-teaming scan; compare with the current production version.
  • Promote: deploy the same artefacts to acceptance and production with environment approvals, using canary or blue/green.
Put in order

An agent delivery pipeline

Exam skills 4.3.4

Arrange the stages of a typical agent CI/CD pipeline.

Log in to try this activity Interactive activities are free with an account.

Pipeline security and requirements

Pipelines authenticate to Azure with workload identity federation: GitHub Actions or Azure DevOps obtain an OpenID Connect token that Microsoft Entra ID trusts for a specific repository, branch or environment, so no client secret is stored. Each environment has its own identity with permissions only on that environment's resources. Production deployments require approvals from designated reviewers.

permissions:
  id-token: write          # allow the job to request an OIDC token
  contents: read
jobs:
  deploy-test:
    environment: test      # environment protection rules and approvals
    steps:
      - uses: actions/checkout@v4
      - uses: azure/login@v2
        with: {client-id: "${{ vars.AZURE_CLIENT_ID }}", tenant-id: "${{ vars.AZURE_TENANT_ID }}",
               subscription-id: "${{ vars.AZURE_SUBSCRIPTION_ID }}"}
      - run: azd provision --no-prompt && azd deploy --no-prompt
      - run: python -m pytest tests/integration && python evals/run_evals.py --threshold 0.9

The CI/CD requirements for an agent solution can therefore be summarized as: everything in source control, IaC for all resources, keyless pipeline authentication, the same artefacts promoted through environments, tests and evaluations as gates, approvals for production and a recorded deployment history.

Spot the bug

A deployment job that cannot sign in or be stopped

Exam skills 4.3.4

Find the lines in this GitHub Actions workflow that cause the problems described.

Log in to try this activity Interactive activities are free with an account.
Worked example

Secrets in the pipeline

A company's deployment pipeline stores a service principal's client secret as a repository secret with Contributor rights on the subscription. Security requires removing long-lived credentials and limiting the pipeline's reach.

Replace the secret with workload identity federation for the repository's environments, create one identity per environment with rights only on that environment's resource group, and require approvals for the production environment. Rotating the secret more often would still leave a long-lived credential in the repository.

Check yourself

How can an infrastructure change be checked before it is applied?

Show answer

With a what-if operation on the Bicep deployment, which shows the changes it would make.

Exam Tips

Remember for the exam

  • Bicep or Terraform for all resources; azd for provision plus deploy; validate with what-if.
  • Pipeline authentication without secrets: workload identity federation (OIDC).
  • Same artefacts promoted through environments, gated by tests, evaluations and approvals.