Courseiva
Design and implement build and release pipelinesmediumMultiple ChoiceObjective-mapped

Running a Rollback Script Automatically After a Failed Schema Migration

Your release pipeline deploys to multiple environments sequentially. The deployment to production fails intermittently due to a database schema migration issue. You need to implement a strategy that automatically rolls back the deployment if the migration fails. What should you do?

Quick Answer

Azure Pipelines' built-in auto-rollback only reverts the application deployment itself — slot swaps or file restores — it doesn't run custom logic. To actually roll back a failed database schema migration, add a post-deployment script that runs a rollback script, reverting the schema via SQL or migration tooling, whenever the deployment step reports failure.

⚠ Common exam trap

Candidates often confuse the built-in 'Auto-rollback' feature (Option A) with a comprehensive rollback solution, not realizing that it only reverts application artifacts and cannot handle stateful changes like database schema migrations, which require custom rollback scripts.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Add a post-deployment script that runs a rollback script on failure.

It directly addresses the requirement to automatically roll back the deployment when a database schema migration fails. By adding a post-deployment script that runs a rollback script on failure, you can execute custom logic (e.g., reverting schema changes using SQL scripts or tools like Entity Framework migrations) immediately after the deployment step detects an error. This approach provides fine-grained control over the rollback process, which is essential for database migrations that cannot be handled by Azure Pipelines' built-in auto-rollback feature, which only reverts the application deployment (e.g., swapping slots or restoring files) and does not execute custom rollback scripts.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Enable 'Auto-rollback' in the release pipeline settings.

    Why it's wrong here

    Azure DevOps does not have a built-in 'Auto-rollback' toggle; rollback must be implemented via scripts.

  • Use a multi-stage YAML pipeline with manual intervention.

    Why it's wrong here

    Manual intervention stops the pipeline; it does not automatically roll back.

  • Configure pre-deployment approval gates.

    Why it's wrong here

    Gates pause deployment but do not automatically roll back.

  • Add a post-deployment script that runs a rollback script on failure.

    Why this is correct

    A rollback script can be triggered on failure to revert changes.

About these practice questions

One of 823 original AZ-400 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

1 more way this is tested on AZ-400

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. A company uses Azure DevOps for CI/CD. They have a multi-stage YAML pipeline that builds a Java application, runs unit tests, and deploys to a test environment. The test environment uses an Azure SQL Database. The pipeline currently runs successfully but the team notices that the test database schema is not always up-to-date. They want to apply database migrations automatically as part of the pipeline. Which tool or task should they integrate?

medium
  • A.Use the Azure SQL Database deployment task to run a SQL script manually.
  • B.Use Azure SQL Database backup and restore to update the schema.
  • C.Add a PowerShell task that runs SQLCMD.
  • D.Integrate Flyway or similar database migration tool in the pipeline.

Why D: Flyway is a dedicated database migration tool that integrates seamlessly with Azure DevOps pipelines, allowing you to version-control and apply schema changes automatically. Unlike ad-hoc scripts, Flyway tracks which migrations have been applied, ensuring the test database schema is always up-to-date without manual intervention.

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This AZ-400 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AZ-400 exam.