Lesson 5 of 5 Maintaining Pipelines

Migrating Classic Pipelines to YAML

This lesson explains why to migrate, what can be exported, and how classic features map to YAML.

Learning outcomes

After completing this lesson, you will be able to:

  • Explain the benefits of YAML.
  • Migrate a classic build pipeline.
  • Map classic release concepts to YAML.
  • Identify differences that affect a migration.

Why migrate

Classic build and release pipelines are defined through a visual interface, and they are stored in Azure DevOps. They work, but the definition is separate from the code. A YAML pipeline lives in the repository, so it gains pull request review, branch-specific changes, and a history that matches the code it builds. Templates enable reuse, and new platform features tend to reach YAML. Microsoft recommends YAML for new pipelines, and organizations can turn off the creation of new classic pipelines through settings.

Migrating a classic build pipeline

Classic build pipelines can be exported directly. Open the pipeline definition, not a run, select the menu with three dots, and choose Export to YAML. The file is a starting point, and it usually needs editing, since some settings do not carry across.

  1. Export

    Download the YAML from the pipeline definition.

  2. Add to the repository

    Commit the file on a branch.

  3. Create a YAML pipeline

    Point a new pipeline at the file.

  4. Move settings

    Recreate triggers, variables and agent settings.

  5. Run side by side

    Compare outputs with the classic pipeline.

  6. Disable the classic pipeline

    Keep it disabled for a time, then delete it.

Put in order

Migrating a classic build

Exam skills 3.6.5

Arrange the steps for moving a classic build pipeline to YAML.

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

Migrating a classic release pipeline

Classic release pipelines have no YAML export. Each task can be viewed as YAML from the task panel, but the structure must be rebuilt by hand. This is where most migration effort lies. The mapping of concepts is shown in the following table.

Classic release conceptYAML equivalent
Release pipelineMulti-stage YAML pipeline
Stagestage with a deployment job
Pre-deployment approvalsApprovals check on an environment
Release gatesEnvironment checks, such as Query Azure Monitor Alerts
Artifact sourcesPipeline artifacts and pipeline resources
Continuous deployment triggertrigger, or a pipeline resource trigger
Deployment groupsVM resources in an environment
Task groupsStep templates
Variable scoped to a stageVariables at stage level
Release retentionRetention leases and project settings

Gates and approvals need careful thought, as they move from the definition of the pipeline to the environment. This actually improves control, since they then apply to all pipelines that use an environment, and cannot be edited by someone who edits only the YAML.

The following diagram maps each classic pipeline item to its YAML replacement.

The migration plan from classic to YAML pipelines. Build pipelines are exported with Export to YAML and tidied; release pipelines have no export, so they are rebuilt as multi-stage YAML with approvals and the Azure Monitor gate moved to environment checks; the 01:00 Sydney schedule becomes a cron expression in UTC.
The scenario is illustrative.
Match the pairs

Classic release concepts in YAML

Exam skills 3.6.5

Match each classic release concept with its YAML equivalent.

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

Differences that catch people out

  • Schedules: YAML schedules use UTC by default, whereas classic pipelines use the organization's local time zone. A nightly build can appear to move after migration.
  • Checkout: a deployment job does not check out source code automatically, unlike a classic build.
  • Variables: secret variables in pipeline settings can be kept, but they should move to variable groups or Key Vault.
  • Triggers: a YAML pipeline with no trigger section runs for all branches.
  • Permissions: pipelines must be authorized to use service connections, agent pools and environments.
  • Branch behaviour: because the YAML is in the repository, each branch can have a different definition.
Troubleshooting

Surprises after migration

Exam skills 3.6.5

Find the cause of each problem that appears after moving to YAML.

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

Moving to GitHub Actions

Some organizations migrate further, from Azure Pipelines to GitHub Actions. GitHub Actions Importer audits existing pipelines, forecasts usage and generates draft workflows. Azure Pipelines YAML and classic pipelines are among its supported sources. As with any automated conversion, the output needs review, particularly for service connections, which become federated credentials, and for checks, which become environment protection rules.

Worked example

Planning a migration

A company has 40 classic build pipelines and 25 classic release pipelines. Each release pipeline uses pre-deployment approvals and an Azure Monitor gate. A nightly build runs at 01:00 in Sydney. What should the migration plan state?

Export the build pipelines with Export to YAML and tidy the output. Rebuild the release pipelines as multi-stage YAML, because there is no release export, moving approvals and gates to environment checks. Convert the nightly schedule to UTC, as YAML cron times are in UTC by default. Moving everything with an automatic export is not possible for the release pipelines, and copying approvals into YAML steps would give up the protection of checks.

Check yourself

What replaces a classic deployment group in YAML?

Show answer

VM resources in an environment, which use an agent installed on each machine.

Exam Tips

Remember for the exam

  • Export to YAML works for classic build pipelines only.
  • Classic release pipelines must be rebuilt as multi-stage YAML.
  • Pre-deployment approvals and gates become environment checks.
  • Task groups become step templates; deployment groups become VM resources.
  • YAML schedules use UTC by default.