Tag: CI/CD

Detect schema drift by using SQL Database Projects (DP-800 Exam Prep)

This post is a part of the DP-800: Developing AI-Enabled Database Solutions Exam Prep Hub.
This topic falls under these sections:
Secure, optimize, and deploy database solutions (35–40%)
   --> Implement CI/CD by using SQL Database Projects
      --> Detect schema drift by using SQL Database Projects


Note that there are 10 practice questions (with answers) at the end of each section to help you solidify your knowledge of the material. Also, there are 4 practice tests with 30 questions each available from the hub's main page below the exam topics section.

Introduction

Understanding schema drift is essential for modern DevOps and database lifecycle management (DLM). The DP-800 exam expects candidates to understand how SQL Database Projects establish the desired database state, how schema drift occurs, how to detect it before deployment, and how to prevent accidental overwrites of production databases.


What is Schema Drift?

Schema drift occurs when the actual database schema no longer matches the schema stored in source control or the SQL Database Project.

In other words:

  • Source control contains the expected design
  • Database contains the actual implementation

If someone changes the production database directly, the database “drifts” away from the project.

Example:

Project contains:

CREATE TABLE Sales.Customer
(
CustomerID INT PRIMARY KEY,
Name NVARCHAR(100)
);

A DBA later runs:

ALTER TABLE Sales.Customer
ADD LoyaltyPoints INT;

The SQL Database Project still contains only:

CustomerID
Name

The live database now contains:

CustomerID
Name
LoyaltyPoints

This difference is schema drift.


Why Schema Drift Is Dangerous

Schema drift creates several problems:

  • unexpected deployment failures
  • overwritten production changes
  • missing documentation
  • inconsistent environments
  • broken CI/CD pipelines
  • difficult troubleshooting
  • unreliable rollback

Organizations using DevOps aim to eliminate manual production changes because every manual change introduces drift.


Common Causes of Schema Drift

Manual Changes

A DBA executes:

ALTER TABLE Products
ADD InternalNotes NVARCHAR(200);

The project is never updated.


Emergency Production Fixes

A production outage occurs.

An engineer fixes the database immediately.

The fix is never committed back into Git.


Hotfix Deployments

A hotfix bypasses the normal deployment pipeline.

The database project remains outdated.


Third-Party Applications

Vendor software automatically creates:

  • indexes
  • tables
  • triggers
  • stored procedures

These objects may not exist in source control.


Automatic Maintenance Scripts

Jobs create:

  • audit tables
  • archive tables
  • logging procedures

If unmanaged, these appear as schema drift.


Desired State vs Actual State

SQL Database Projects follow a declarative model.

Instead of saying:

Execute these SQL commands.

They say:

The database should look like this.

Deployment tools compare:

Desired State (Project)

Current Database

Generate Deployment Script

The comparison process naturally identifies drift.


SQL Database Projects as the Source of Truth

A SQL Database Project should become the organization’s single source of truth.

Everything should originate from:

  • Git
  • pull requests
  • code reviews
  • approved deployments

Not from:

  • SSMS manual edits
  • Azure Data Studio changes
  • production hotfixes
  • direct ALTER TABLE statements

How Schema Comparison Works

The deployment engine compares:

Project Object

Database Object

It evaluates:

  • tables
  • columns
  • indexes
  • views
  • procedures
  • functions
  • triggers
  • users
  • roles
  • constraints
  • sequences

Every difference is identified before deployment.


Schema Compare

Schema Compare compares:

Source

Target

Possible comparisons include:

Project → Database

Database → Project

Database → Database

Project → Project

The generated report identifies:

  • missing objects
  • additional objects
  • modified objects
  • renamed objects
  • changed permissions

Example Drift Detection

Project contains:

CREATE TABLE Employee
(
EmployeeID INT,
Name NVARCHAR(100)
);

Database contains:

CREATE TABLE Employee
(
EmployeeID INT,
Name NVARCHAR(100),
Department NVARCHAR(50)
);

Schema Compare reports:

Table: Employee
Column missing from project:
Department

Drift During Deployment

Suppose:

Project:

Customer
Orders
Invoices

Production:

Customer
Orders
Invoices
AuditLog

If the deployment option allows dropping extra objects:

Deployment may attempt:

DROP TABLE AuditLog;

This could remove an important production table.

Understanding deployment options is therefore critical.


Deployment Reports

Before publishing, SQL Database Projects can generate:

  • deployment report
  • deployment script

The deployment report shows:

  • objects added
  • objects removed
  • objects modified

Reviewing the report is a best practice.


Deployment Script Review

Instead of deploying immediately:

Generate Script

Review

Approve

Deploy

This catches accidental schema drift before changes reach production.


Ignore Options

Some differences are expected.

Deployment settings allow ignoring:

  • whitespace
  • object order
  • permissions
  • filegroups
  • partition schemes
  • users
  • role memberships
  • extended properties

Ignoring irrelevant differences reduces false positives.


Drift Detection in CI/CD Pipelines

Typical pipeline:

Developer commits

Build project

Run validation

Compare schema

Detect drift

Generate report

Approve

Deploy

If drift exists:

Pipeline can:

  • fail
  • warn
  • require manual approval

Preventing Schema Drift

Best practices include:

Use Source Control

Every schema change should originate in Git.


Require Pull Requests

No direct commits to the main branch.


Block Direct Production Changes

Restrict:

  • ALTER
  • CREATE
  • DROP

to deployment pipelines.


Automate Deployments

Avoid manual publishing whenever possible.


Review Deployment Reports

Always inspect changes before production deployment.


Synchronize Hotfixes

If an emergency fix is applied directly to production:

  1. Update the SQL Database Project.
  2. Commit the change to source control.
  3. Redeploy from the project.

Detecting Drift with SqlPackage

SqlPackage can compare a DACPAC with a target database.

Example:

SqlPackage /Action:DeployReport

or

SqlPackage /Action:Script

These operations generate reports showing differences before deployment.


Azure DevOps and GitHub Actions

CI/CD pipelines commonly:

  • build the SQL Database Project
  • produce a DACPAC
  • compare with the target database
  • generate deployment scripts
  • detect unexpected schema changes
  • require approval before deployment

This ensures every deployment is repeatable and auditable.


Handling Intentional Drift

Sometimes production intentionally differs.

Examples:

  • monitoring tables
  • audit tables
  • replication objects
  • vendor-managed objects

Possible approaches:

  • exclude those objects
  • maintain separate projects
  • use deployment filters
  • configure ignore settings

Schema Drift vs Data Drift

These terms are different.

Schema DriftData Drift
Structure changesData values change
TablesRows
ColumnsRecords
IndexesBusiness data
ConstraintsTransactions

Example:

Schema drift:

ADD COLUMN Salary

Data drift:

Salary changed from 50000 to 70000

Best Practices

  • Treat the SQL Database Project as the single source of truth.
  • Never make untracked production schema changes.
  • Use pull requests and code reviews for every schema modification.
  • Generate deployment reports before publishing.
  • Review deployment scripts for unintended object drops.
  • Integrate schema comparison into CI/CD pipelines.
  • Keep production synchronized with source control after emergency fixes.
  • Use deployment options carefully to avoid deleting valid production objects.
  • Automate validation whenever possible.
  • Document intentional schema differences.

DP-800 Exam Tips

Remember these key exam points:

  • Schema drift means the database no longer matches the project.
  • SQL Database Projects define the desired database state.
  • Schema Compare identifies differences before deployment.
  • Deployment reports should always be reviewed.
  • CI/CD pipelines should automatically detect drift.
  • Source control should remain the authoritative definition of the schema.
  • Direct production modifications increase deployment risk.
  • Emergency fixes should always be merged back into the SQL Database Project.

Practice Exam Questions

Question 1

A database administrator manually adds a column to a production table without updating the SQL Database Project. What has occurred?

A. Data corruption

B. Schema drift

C. Query regression

D. Database fragmentation

Answer: B

Explanation: Schema drift occurs whenever the deployed database differs from the schema stored in the SQL Database Project.


Question 2

What is considered the desired state during SQL Database Project deployments?

A. The production database

B. The deployment report

C. The SQL Database Project

D. The Query Store

Answer: C

Explanation: SQL Database Projects define the desired schema used to generate deployment changes.


Question 3

Which tool compares a SQL Database Project with an existing database?

A. SQL Profiler

B. Database Mail

C. Activity Monitor

D. Schema Compare

Answer: D

Explanation: Schema Compare analyzes differences between project schemas and deployed databases.


Question 4

Why should deployment reports be reviewed before publishing?

A. To improve indexing

B. To compress data

C. To identify unexpected schema changes

D. To rebuild statistics

Answer: C

Explanation: Deployment reports identify additions, deletions, and modifications before changes are applied.


Question 5

Which practice best minimizes schema drift?

A. Allow direct production changes

B. Disable source control

C. Store only stored procedures in Git

D. Require all schema changes through source control

Answer: D

Explanation: Requiring every schema modification to flow through source control prevents unmanaged changes.


Question 6

Which deployment option helps prevent accidental removal of valid production objects?

A. Review deployment scripts before publishing

B. Disable indexes

C. Shrink the database

D. Disable Query Store

Answer: A

Explanation: Reviewing generated scripts allows teams to identify unintended DROP statements before deployment.


Question 7

An emergency production fix was made directly on the database. What should happen next?

A. Ignore the change

B. Remove the production change immediately

C. Update the SQL Database Project and commit the change

D. Rebuild every index

Answer: C

Explanation: Production hotfixes should be reflected in the project and committed to source control to eliminate schema drift.


Question 8

Which pipeline stage commonly detects schema drift?

A. Backup compression

B. Schema comparison before deployment

C. Statistics updates

D. Data import

Answer: B

Explanation: CI/CD pipelines typically compare the desired schema with the target database before deployment.


Question 9

Which statement correctly describes schema drift?

A. It refers to changes in business data.

B. It indicates poor query performance.

C. It describes missing backups.

D. It occurs when the deployed schema differs from the SQL Database Project.

Answer: D

Explanation: Schema drift specifically concerns differences between database structure and the project’s intended schema.


Question 10

Why are ignore settings sometimes configured during schema comparison?

A. To disable security

B. To ignore expected differences that should not trigger deployments

C. To improve backup speed

D. To compress deployment packages

Answer: B

Explanation: Ignore settings reduce false positives by excluding acceptable differences such as permissions or extended properties from deployment comparisons.


Go to the DP-800 Exam Prep Hub main page

Integrate Foundry projects with Continuous Integration and Continuous Deployment (CI/CD) pipelines (AI-103 Exam Prep)

This post is a part of the AI-103: Develop AI Apps and Agents on Azure Exam Prep Hub. 
This topic falls under these sections:
Plan and manage an Azure AI solution (25–30%)
--> Set up AI solutions in Foundry
--> Integrate Foundry projects with Continuous Integration and Continuous Deployment (CI/CD) pipelines


Note that there are 10 practice questions (with answers and explanations) at the end of each section to help you solidify your knowledge of the material. Also, there are 2 practice tests with 60 questions each available from the hub's main page below the exam topics section.

Introduction

Modern AI applications and agent-based systems are continuously evolving.

Organizations frequently update:

  • AI models
  • Prompts
  • Agent workflows
  • APIs
  • Retrieval systems
  • Infrastructure
  • Security configurations

Manual deployment processes are slow, error-prone, and difficult to scale.

To solve these challenges, organizations use:

  • Continuous Integration (CI)
  • Continuous Deployment (CD)
  • Automated testing
  • Infrastructure-as-Code (IaC)
  • Automated validation pipelines

The AI-103: Develop AI Apps and Agents on Azure certification exam tests your understanding of how to integrate Azure AI Foundry projects into CI/CD pipelines.

For the AI-103 exam, you should understand:

  • CI/CD concepts
  • Azure DevOps pipelines
  • GitHub Actions workflows
  • Infrastructure-as-Code
  • Automated AI deployment workflows
  • Model versioning
  • Deployment automation
  • Testing and validation
  • Environment management
  • Rollback strategies
  • Monitoring deployment health

What Is CI/CD?

CI/CD stands for:

  • Continuous Integration
  • Continuous Deployment (or Continuous Delivery)

CI/CD automates software and AI deployment processes.


Continuous Integration (CI)

Continuous Integration focuses on:

  • Automatically building code
  • Running automated tests
  • Validating changes
  • Detecting issues early

Developers frequently merge changes into shared repositories.


Continuous Deployment (CD)

Continuous Deployment automates:

  • Application releases
  • Model deployments
  • Infrastructure updates
  • Environment promotion

CD ensures new versions are deployed safely and consistently.


Why CI/CD Matters for AI Solutions

AI systems are more complex than traditional applications because they include:

  • Models
  • Prompts
  • Retrieval pipelines
  • Vector indexes
  • Agent workflows
  • Tool integrations

CI/CD helps ensure:

  • Reliable deployments
  • Repeatable processes
  • Faster releases
  • Reduced downtime
  • Safer experimentation

Azure AI Foundry and CI/CD

Azure AI Foundry integrates with:

  • Azure DevOps
  • GitHub Actions
  • Infrastructure-as-Code tools
  • Azure CLI
  • SDKs
  • REST APIs

This enables automated AI workflows.


Source Control for AI Projects

AI projects should use source control systems.

Common repositories include:

  • GitHub
  • Azure Repos

What Should Be Stored in Source Control?

Common AI assets include:

  • Application code
  • Prompt templates
  • Agent configurations
  • Infrastructure definitions
  • Deployment scripts
  • Evaluation workflows
  • Test cases
  • CI/CD pipeline definitions

What Should NOT Be Stored in Source Control?

Never store:

  • Secrets
  • API keys
  • Passwords
  • Certificates
  • Sensitive credentials

Use Azure Key Vault instead.


Azure DevOps

Azure DevOps provides:

  • Repositories
  • Build pipelines
  • Release pipelines
  • Work tracking
  • Artifact management

Azure DevOps is commonly used for enterprise AI deployments.


GitHub Actions

GitHub Actions supports:

  • Automated workflows
  • Build automation
  • Testing pipelines
  • Deployment automation
  • CI/CD orchestration

GitHub Actions is widely used for AI applications hosted in GitHub repositories.


Infrastructure-as-Code (IaC)

Infrastructure-as-Code automates infrastructure provisioning.

Instead of manually creating resources, infrastructure is defined in code.


Benefits of IaC

IaC provides:

  • Repeatability
  • Version control
  • Consistency
  • Automation
  • Reduced configuration drift

Common IaC Tools in Azure

Common Azure IaC tools include:

  • ARM templates
  • Bicep
  • Terraform

Bicep

Bicep is a declarative language for Azure infrastructure.

Used to deploy:

  • Azure OpenAI resources
  • Azure AI Search
  • Storage accounts
  • Networking resources
  • Key Vault
  • App Services

Terraform

Terraform is a multi-cloud Infrastructure-as-Code tool.

Useful for:

  • Hybrid environments
  • Multi-cloud deployments
  • Large enterprise automation

Automating Azure AI Resource Deployment

CI/CD pipelines can automatically provision:

  • Azure OpenAI
  • Azure AI Search
  • Cosmos DB
  • Azure Functions
  • App Service
  • Networking
  • Monitoring services

Automating Model Deployments

Model deployment pipelines may automate:

  • Model version selection
  • Deployment creation
  • Endpoint configuration
  • Scaling configuration
  • Rollback management

Model Versioning

Versioning is critical for AI deployments.

Benefits include:

  • Safer updates
  • Rollback support
  • Testing new versions
  • Comparing performance

Environment Management

AI solutions commonly use multiple environments.

Typical environments include:

  • Development
  • Testing
  • Staging
  • Production

Development Environment

Used for:

  • Experimentation
  • Initial testing
  • Prompt development
  • Rapid iteration

Testing Environment

Used for:

  • Automated testing
  • Integration testing
  • Validation workflows

Staging Environment

Used for:

  • Final validation
  • Production-like testing
  • User acceptance testing

Production Environment

Used for:

  • Live workloads
  • Enterprise applications
  • Customer-facing systems

Production environments require:

  • Strong monitoring
  • Security controls
  • Scalability
  • High availability

Automated Testing in AI Pipelines

Testing AI systems is more complex than traditional software testing.

AI pipelines should validate:

  • Functional behavior
  • Prompt quality
  • Retrieval quality
  • Latency
  • Safety
  • Reliability

Unit Testing

Unit testing validates:

  • Individual functions
  • APIs
  • Tool integrations
  • Components

Integration Testing

Integration testing validates interactions between:

  • Models
  • APIs
  • Search systems
  • Databases
  • Agents

Prompt Evaluation

Prompt evaluation helps assess:

  • Response quality
  • Groundedness
  • Hallucinations
  • Relevance
  • Consistency

Automated Evaluation Pipelines

Evaluation pipelines may measure:

  • Accuracy
  • Latency
  • Token usage
  • Toxicity
  • Retrieval precision

Prompt Flow and CI/CD

Prompt Flow can integrate into CI/CD pipelines.

Prompt Flow supports:

  • Workflow orchestration
  • Evaluation pipelines
  • Prompt testing
  • Tool integration

Deployment Strategies

Safe deployment strategies reduce risk.


Blue-Green Deployments

Blue-green deployments use two environments:

  • Current production environment
  • New deployment environment

Traffic switches after validation.

Benefits:

  • Reduced downtime
  • Easy rollback
  • Safer deployments

Canary Deployments

Canary deployments release updates gradually.

Benefits:

  • Reduced deployment risk
  • Easier issue detection
  • Controlled rollout

Rolling Deployments

Rolling deployments update systems incrementally.

Benefits:

  • Minimal downtime
  • Gradual infrastructure replacement

Rollback Strategies

Rollback mechanisms are critical.

Rollbacks may restore:

  • Previous model versions
  • Prior prompts
  • Earlier infrastructure states

Deployment Approval Gates

Approval gates help control production releases.

Approvals may be required before:

  • Production deployment
  • Model upgrades
  • Infrastructure changes

Security in CI/CD Pipelines

Security is a major AI-103 topic.


Azure Key Vault Integration

Pipelines should retrieve secrets securely from:

  • Azure Key Vault

Examples include:

  • API keys
  • Connection strings
  • Certificates

Managed Identities

Managed identities reduce the need for stored credentials.

Benefits:

  • Improved security
  • Simplified authentication
  • Reduced secret exposure

Role-Based Access Control (RBAC)

RBAC limits access to:

  • Deployments
  • Resources
  • Pipelines
  • Secrets

Monitoring CI/CD Pipelines

Pipelines should monitor:

  • Build failures
  • Deployment failures
  • Performance regressions
  • AI quality degradation

Azure Monitor

Azure Monitor supports:

  • Metrics
  • Alerts
  • Logging
  • Diagnostics

Application Insights

Application Insights helps monitor:

  • API latency
  • Failures
  • Dependency performance
  • User behavior

AI-Specific Monitoring

AI systems should monitor:

  • Token usage
  • Hallucination rates
  • Retrieval quality
  • Tool execution failures
  • Prompt performance

Common AI-103 CI/CD Scenarios

Scenario 1: Enterprise AI Copilot

Requirements:

  • Frequent prompt updates
  • Safe production releases
  • Automated testing

Recommended Approach:

  • GitHub Actions
  • Prompt Flow evaluations
  • Canary deployments

Scenario 2: Large-Scale AI Platform

Requirements:

  • Infrastructure automation
  • Multi-environment deployment
  • Enterprise governance

Recommended Approach:

  • Azure DevOps
  • Bicep or Terraform
  • Approval gates

Scenario 3: AI Agent Workflow System

Requirements:

  • Frequent workflow updates
  • Tool integration testing
  • Prompt validation

Recommended Approach:

  • Automated evaluation pipelines
  • Integration testing
  • Blue-green deployment strategy

Cost Optimization in CI/CD

CI/CD pipelines can increase operational costs.


Cost Optimization Strategies

Use Automated Cleanup

Remove:

  • Temporary environments
  • Test resources
  • Unused deployments

Optimize Test Frequency

Run expensive evaluations only when necessary.


Use Smaller Models for Testing

Smaller models reduce:

  • Token usage
  • Compute costs
  • Evaluation expenses

Common AI-103 Exam Tips

Understand CI/CD Fundamentals

Know:

  • Continuous Integration
  • Continuous Deployment
  • Automated testing
  • Deployment automation

Learn Deployment Strategies

Understand:

  • Blue-green deployments
  • Canary deployments
  • Rolling deployments
  • Rollback strategies

Know Infrastructure-as-Code Concepts

Understand:

  • Bicep
  • Terraform
  • ARM templates

Understand AI-Specific Testing

AI systems require testing for:

  • Prompt quality
  • Groundedness
  • Safety
  • Retrieval accuracy
  • Latency

Summary

Integrating Azure AI Foundry projects with CI/CD pipelines enables organizations to:

  • Automate deployments
  • Improve reliability
  • Increase scalability
  • Reduce operational risk
  • Accelerate AI delivery

For the AI-103 exam, you should understand:

  • CI/CD fundamentals
  • Azure DevOps pipelines
  • GitHub Actions workflows
  • Infrastructure-as-Code
  • Automated AI deployment strategies
  • Environment management
  • AI testing pipelines
  • Monitoring and observability
  • Secure deployment practices
  • Rollback and release strategies

Strong CI/CD practices are essential for building production-grade AI applications and agent-based systems on Azure.


Practice Exam Questions

Question 1

What does CI/CD stand for?

A. Continuous Integration and Continuous Deployment
B. Centralized Integration and Continuous Diagnostics
C. Continuous Inspection and Cloud Deployment
D. Centralized Infrastructure and Cloud Distribution

Answer

A. Continuous Integration and Continuous Deployment

Explanation

CI/CD automates software and AI deployment workflows.


Question 2

Which Azure service is commonly used for enterprise CI/CD pipelines?

A. Azure DevOps
B. Azure Backup
C. Azure DNS
D. Azure Files

Answer

A. Azure DevOps

Explanation

Azure DevOps provides build, release, and deployment pipeline capabilities.


Question 3

Which GitHub feature supports automated workflow execution for deployments?

A. GitHub Actions
B. GitHub Storage
C. GitHub Search
D. GitHub Monitor

Answer

A. GitHub Actions

Explanation

GitHub Actions automates workflows, testing, and deployments.


Question 4

Which deployment strategy uses two environments and switches traffic after validation?

A. Rolling deployment
B. Blue-green deployment
C. Canary deployment
D. Manual deployment

Answer

B. Blue-green deployment

Explanation

Blue-green deployments reduce downtime and simplify rollback.


Question 5

Which Azure service securely stores secrets for CI/CD pipelines?

A. Azure Key Vault
B. Azure Monitor
C. Azure Firewall
D. Azure CDN

Answer

A. Azure Key Vault

Explanation

Azure Key Vault securely stores secrets and credentials.


Question 6

Which Infrastructure-as-Code language is specifically designed for Azure?

A. Bicep
B. SQL
C. JavaScript
D. HTML

Answer

A. Bicep

Explanation

Bicep is a declarative Infrastructure-as-Code language for Azure.


Question 7

What is the primary purpose of canary deployments?

A. Eliminate monitoring
B. Gradually release updates to reduce risk
C. Replace version control
D. Encrypt model endpoints

Answer

B. Gradually release updates to reduce risk

Explanation

Canary deployments expose updates to a subset of users first.


Question 8

Which type of testing validates interactions between models, APIs, and databases?

A. Unit testing
B. Integration testing
C. Syntax testing
D. Deployment testing

Answer

B. Integration testing

Explanation

Integration testing validates component interactions.


Question 9

Which Azure service helps monitor application telemetry and diagnostics?

A. Application Insights
B. Azure DNS
C. Azure Backup
D. Azure Files

Answer

A. Application Insights

Explanation

Application Insights provides telemetry and monitoring capabilities.


Question 10

Which Azure feature reduces the need to store credentials directly in pipelines?

A. Managed identities
B. Public IP addresses
C. Azure CDN
D. Static tokens

Answer

A. Managed identities

Explanation

Managed identities provide secure authentication without storing credentials.


Go to the AI-103 Exam Prep Hub main page