Azure Database Migration Service
Complete the full lesson to earn 25 points — 50 with Pro
Work through each section, then tap “Mark as Complete” on the last one.
✦ Skip the page breaks, the wait, and see fewer ads — read each lesson on a single page with Pro
Lesson: Azure Database Migration Service (DMS)
Introduction: Why Database Migration Matters
In the modern enterprise landscape, moving data from on-premises environments or legacy hosted solutions to the cloud is a fundamental requirement for agility and scalability. However, moving a database is rarely as simple as copying a file from one folder to another. Databases are complex, stateful systems that require high consistency, minimal downtime, and rigorous security throughout the transition process. If a migration is handled poorly, organizations face extended outages, data corruption, or loss of critical business intelligence.
The Azure Database Migration Service (DMS) is a fully managed service designed to simplify, guide, and automate the migration of your databases to Azure. Instead of manually scripting complex ETL (Extract, Transform, Load) processes or managing third-party migration tools, DMS provides a unified interface to move various database engines—such as SQL Server, PostgreSQL, MySQL, and MongoDB—into Azure SQL Database, Azure SQL Managed Instance, or Azure Virtual Machines.
Understanding how to use DMS effectively is critical for any data engineer or cloud architect. It bridges the gap between legacy infrastructure and modern cloud architecture, allowing teams to focus on optimizing their applications rather than troubleshooting connectivity issues during a move. This lesson will explore the architecture, configuration, and best practices required to execute successful migrations using Azure DMS.
Understanding the Core Architecture of Azure DMS
Azure Database Migration Service functions by acting as an intermediary agent that orchestrates the data movement between your source and your destination. It is built upon the same technology that powers the Data Migration Assistant (DMA), a tool used for assessing database compatibility. When you initiate a migration through DMS, the service provisions a dedicated compute resource in your Azure subscription to handle the heavy lifting of data transfer.
The service supports two primary types of migrations: offline and online. An offline migration is simpler but requires that you take your application down while the data is being copied. An online migration is designed for scenarios where downtime must be kept to an absolute minimum; the service performs an initial load of data and then continuously synchronizes the changes (transactions) that occur on the source until you are ready to "cut over" to the new environment.
Callout: Online vs. Offline Migration Strategies
Choosing between online and offline migrations is the most significant decision in your migration plan. An offline migration is generally faster and less complex to monitor because it is a one-time copy operation. However, it requires a maintenance window where the source database is read-only or disconnected. An online migration allows the source database to remain active and available, but it requires a persistent network connection and constant monitoring of the synchronization latency between the source and the target.
Planning and Assessment: Before You Start
Before you even touch the Azure portal to provision a migration service, you must perform a thorough assessment of your source environment. Migrating a database that is incompatible with the target platform will result in failure regardless of how well the service is configured. The primary tool for this assessment is the Data Migration Assistant (DMA).
Steps for Pre-Migration Assessment
- Download and Install DMA: Install the Data Migration Assistant on a machine that has network access to your source database server.
- Run the Assessment: Connect to your source instance and select the target Azure platform. The tool will analyze your schema, stored procedures, and data types for compatibility issues.
- Review Compatibility Reports: The report will categorize findings into "Breaking Changes" and "Behavior Changes." Breaking changes must be fixed before the migration can proceed.
- Remediate Issues: Modify your T-SQL scripts or database objects to align with the constraints of the Azure target platform.
- Verify Performance Requirements: Evaluate the SKU of your target Azure SQL database to ensure it can handle the workload currently supported by your on-premises hardware.
Tip: Don't Skip the Assessment
Many migration failures occur because engineers assume that because a database runs on SQL Server 2016, it will migrate perfectly to Azure SQL Managed Instance. While the engines are similar, features like cross-database queries, linked servers, or specific CLR assemblies might behave differently or be unsupported in the cloud. Always run the DMA assessment to identify these hidden roadblocks.
Configuring the Azure Database Migration Service
Once your assessment is complete and your environment is ready, you can proceed to set up the DMS instance. The setup process involves creating the service resource in your Azure subscription and then creating specific migration projects within that service.
Step-by-Step Provisioning
- Create the DMS Resource: In the Azure portal, search for "Azure Database Migration Service" and click "Create." You will need to select a subscription, a resource group, and a name for the service.
- Select the Tier: Choose between the Standard or Premium tier. For most enterprise migrations, the Premium tier is recommended because it provides the necessary performance for large-scale data movement and supports online migrations.
- Networking Configuration: DMS must be placed in a Virtual Network (VNet) that has connectivity to your source database. This is a critical step; if your source is on-premises, you must have a VPN or ExpressRoute established, or you must use a self-hosted integration runtime if applicable.
Creating a Migration Project
A migration project acts as a container for your migration tasks. Within a project, you define:
- Source Server Details: The server name, port, and authentication credentials.
- Target Server Details: The destination Azure SQL instance or VM.
- Database Selection: A list of the specific databases you wish to migrate.
- Migration Type: Selection of Online or Offline mode.
Practical Example: Migrating SQL Server to Azure SQL Managed Instance
Let’s walk through a scenario where we move an on-premises SQL Server database to an Azure SQL Managed Instance using an online migration. This is a common requirement for organizations migrating legacy applications that rely on features like SQL Agent jobs or cross-database queries.
Prerequisites
- An established VPN or ExpressRoute between your on-premises network and the Azure VNet.
- A backup share accessible by both the source SQL Server and the Azure SQL Managed Instance. This is crucial for the "Restore" method of migration.
- Appropriate permissions on the source server (sysadmin) and the target instance (managed instance administrator).
The Workflow
- Create a Backup: Ensure that you have a full backup and subsequent transaction log backups of your source database.
- Configure Permissions: Grant the database migration service account access to the shared folder where the backups are stored.
- Initiate the Project: Inside your DMS project, select "SQL Server" as the source and "Azure SQL Managed Instance" as the target.
- Configure Network: Ensure the DMS instance can communicate with the source server on the standard SQL port (usually 1433).
- Start Migration: DMS will begin restoring the full backup to the target instance. Once the full backup is complete, DMS will monitor the transaction logs and continuously apply them to the target.
Code Snippet: Validating Connectivity
Before initiating the migration, it is best practice to verify connectivity from the machine hosting your migration tools to the target Azure endpoint. You can use PowerShell for this:
# Test connection to Azure SQL Managed Instance
$targetServer = "your-managed-instance.database.windows.net"
$port = 1433
try {
$socket = New-Object System.Net.Sockets.TcpClient($targetServer, $port)
Write-Host "Connectivity to $targetServer on port $port is successful." -ForegroundColor Green
$socket.Close()
}
catch {
Write-Host "Failed to connect to $targetServer. Check VNet and Firewall rules." -ForegroundColor Red
}
Note: The Importance of Port 1433
Azure SQL Managed Instance requires specific inbound rules in your Network Security Group (NSG) to allow traffic from the migration service. Ensure that your NSG is not blocking port 1433 for the subnet where your managed instance resides.
Best Practices for Successful Migrations
Migration is as much about process as it is about technology. Even with the best tools, a lack of planning leads to failure.
1. Perform Dry Runs
Never perform your production migration as the first attempt. Create a staging environment in Azure that mirrors your production target, and perform a full migration test. This allows you to measure the time required for the data transfer and identify any unexpected performance bottlenecks.
2. Monitor Network Latency
The speed of your migration is dictated by the bandwidth between your source and Azure. If you are migrating terabytes of data over a limited VPN, the migration will take significantly longer than expected. Use tools like iPerf to measure the throughput of your connection before starting a large migration project.
3. Cleanup After Migration
Once the migration is complete and you have verified the data integrity, remember to decommission the DMS resource. Leaving the service running incurs unnecessary costs. Additionally, revoke any temporary permissions you granted to the migration service account to maintain a "least privilege" security posture.
4. Handle Login Migrations
DMS moves your database data, but it does not automatically move server-level logins, jobs, or credentials. You must manually script out your logins and SQL Agent jobs from the source server and recreate them on the target Azure SQL Managed Instance. Failure to do this will result in an application that cannot connect to the database even if the data is successfully migrated.
Comparison of Migration Options
When choosing a path to the cloud, it is helpful to understand how DMS stacks up against other methods.
| Method | Best For | Complexity | Downtime |
|---|---|---|---|
| Azure DMS | Complex migrations, online requirements | Moderate | Minimal |
| Backup and Restore | Simple, offline migrations | Low | Moderate |
| Transactional Replication | High-availability needs | High | Near-Zero |
| Data Factory (ADF) | Moving data between heterogeneous sources | Moderate | Variable |
Common Pitfalls and How to Avoid Them
Pitfall 1: Insufficient Permissions
The migration service requires specific permissions to read from the source and write to the target. A common mistake is using a standard user account that lacks the sysadmin role on the source SQL Server. Always use a dedicated service account with the minimum required permissions to perform backups and read data.
Pitfall 2: Ignoring Collation Mismatch
Collation settings define how text data is sorted and compared. If your source database uses a different collation than the target, you will face errors during query execution after the migration. Always ensure the collation of your target database matches the source exactly.
Pitfall 3: Not Accounting for Large Objects (LOB)
Tables containing large amounts of binary data or text (BLOBs) can significantly increase the time required for migration. If you have extremely large tables, consider using bulk-load options or partitioning the data migration into smaller batches.
Pitfall 4: Neglecting Application Connection Strings
After the migration, your application will need to point to the new Azure endpoint. Many teams forget to update their application configuration files or DNS records until the final moment. Prepare a cutover plan that includes a checklist for updating connection strings across all application tiers.
Callout: The "Cutover" Moment
The cutover is the point of no return. During an online migration, this is when you stop all traffic to the source database, allow the final transaction logs to sync to the target, and then point your application to the new Azure database. Practice this process multiple times in a development environment to ensure your team knows exactly how to handle the final sync and verification steps.
Advanced Troubleshooting: When Things Go Wrong
Even with meticulous planning, you may encounter errors during the migration process. Here are the most common scenarios and how to address them.
Connectivity Errors
If the migration fails to start, the most likely culprit is the network. Use the Test-NetConnection cmdlet in PowerShell to verify that the source server is reachable from the machine where your integration runtime is hosted. If you are using a self-hosted integration runtime, check the event logs on the host machine for specific connectivity errors.
Data Validation Failures
Sometimes the data moves, but it doesn't look correct on the target. This often happens due to encoding issues or differences in how data types are handled. Always run a row-count validation between the source and target tables. You can use simple SQL queries to compare row counts:
-- Run on Source
SELECT COUNT(*) FROM dbo.Orders;
-- Run on Target
SELECT COUNT(*) FROM dbo.Orders;
If the counts do not match, you will need to examine the DMS logs to see if specific rows were skipped or if errors occurred during the bulk insert process.
Performance Bottlenecks
If the migration is running slower than expected, check the resource utilization on both the source and target. On the source, check for high disk I/O or CPU usage that might be throttling the backup process. On the target, check if the Azure SQL Database is hitting its DTU (Database Transaction Unit) or vCore limits. If the target is hitting its limit, you may need to temporarily scale up the service tier to allow the migration to complete faster, then scale it back down afterward.
Security Considerations
Moving data is a sensitive operation. When using Azure DMS, you must ensure that your data is protected both in transit and at rest.
- Encryption in Transit: Azure DMS uses TLS to encrypt the data moving between the source and target. Ensure that your source server is configured to support encrypted connections.
- Access Control: Use Azure Role-Based Access Control (RBAC) to limit who can manage the migration service. Only authorized database administrators should have the ability to initiate or terminate migration projects.
- Network Isolation: Whenever possible, use private endpoints for your Azure resources. This ensures that your database traffic never traverses the public internet, reducing the attack surface.
Future-Proofing Your Migration Strategy
Technology moves quickly, and your migration strategy should be flexible. As you move toward a cloud-native architecture, consider whether the database engine you are migrating to is the right long-term fit. For example, while moving a SQL Server database to an Azure VM is the easiest path (a "lift and shift"), it may not provide the same management benefits as moving to Azure SQL Managed Instance.
Periodically review your Azure footprint. Use the Azure Advisor tool to get recommendations on cost, security, and performance for your newly migrated databases. The work doesn't end when the migration is finished; ongoing optimization is the key to maintaining a healthy data platform.
Key Takeaways
- Assessment is Mandatory: Never skip the Data Migration Assistant (DMA) assessment. Identifying compatibility issues early saves hours of troubleshooting later.
- Choose the Right Migration Type: Use offline migrations for small, low-criticality databases and online migrations for production workloads requiring minimal downtime.
- Plan for Infrastructure: Remember that DMS is not just about the data; it’s about the network. Ensure your VPN, ExpressRoute, and firewall rules are correctly configured before initiating the migration.
- Don't Forget the "Extras": Logins, jobs, and cross-database dependencies are not automatically migrated. You must account for these manually to ensure a functional application post-migration.
- Dry Runs are Your Best Friend: Conduct at least one full-scale test in a staging environment to validate your migration timeline and identify potential bottlenecks.
- Least Privilege Matters: Always use service accounts with the minimum necessary permissions and decommission the DMS resource once the migration is complete to optimize costs and security.
- Validation is Essential: Always perform data validation (row counts and consistency checks) after the migration to ensure that the data on the target is an exact replica of the source.
By following these guidelines and understanding the underlying architecture of the Azure Database Migration Service, you can confidently lead your organization's transition to the cloud, ensuring that your data remains secure, consistent, and available throughout the entire process. Remember, a successful migration is defined not by how fast it is completed, but by the stability and performance of the platform once the transition is finalized.
Reach the last section to complete this lesson and earn points — you're on section 1 of 10.
- Introduction to Azure SQL Services
- Introduction to Azure SQL Services Quiz5q
- Azure SQL Database Deployment
- Azure SQL Database Deployment Quiz5q
- Azure SQL Managed Instance
- Azure SQL Managed Instance Quiz5q
- SQL Server on Azure VMs
- SQL Server on Azure VMs Quiz5q
- Elastic Pools Configuration
- Elastic Pools Configuration Quiz5q
- Serverless SQL Database
- Serverless SQL Database Quiz5q
Enjoying the courses?
Everything stays free. Pro shows fewer ads, doubles the points you earn on every lesson and quiz so you progress twice as fast, unlocks half of every practice exam — plus full case studies — with the Learn & Exam study modes, and lets you read each lesson on one page.
- ✓ Fewer advertisements
- ✓ 2× points per lesson & quiz
- ✓ 50% of every exam unlocked
- ✓ Learn & Exam modes
- ✓ Distraction-free lessons