Migrating SQL Server to Azure step by step: backup to URL, Log Replay Service, Managed Instance link, DMS and .bacpac

There are at least six ways to move a SQL Server database to Azure, and which ones you can use depends on the target. This guide helps you choose the target and the route, and then walks through each route with its prerequisites, the commands and the switch: native backup and restore, Log Replay Service, the Managed Instance link, Azure Database Migration Service, a .bacpac with SqlPackage and transactional replication. It ends with what never moves with the database, the first days after the move, a cutover checklist and the errors that come up most.

Choose the target, then the route

The target decides which routes exist. Azure runs a SQL Server database in three ways, and they differ in what your database is still allowed to do:

  • Azure SQL Managed Instance: a managed instance with SQL Server Agent, cross-database queries, Database Mail and server-level objects. It restores native backups from Azure Blob Storage, so all routes to it are based on backups or on the transaction log. Not available: FILESTREAM and FileTable, xp_cmdshell, Windows logins (Microsoft Entra instead). Limited: CLR (only from binary), Service Broker (only between managed instances), linked servers (only to SQL Server and Azure SQL), In-Memory OLTP (only in Business Critical). Up to 32 TB in next-gen General Purpose and 16 TB in Business Critical.
  • Azure SQL Database, including Hyperscale: one database without an instance. No SQL Server Agent, no cross-database queries or USE, no linked servers, CLR, Service Broker or Database Mail, no Windows logins. It does not accept a .bak: the data arrives through a .bacpac, Azure DMS or transactional replication. Up to 4 TB in General Purpose and Business Critical, up to 128 TB in Hyperscale.
  • SQL Server on an Azure VM: your own SQL Server, so everything that works today keeps working, and every route you know from on-premises works too: backup and restore from Blob Storage or a disk, log shipping, an availability group or a distributed availability group, Azure DMS. You keep patching, backups and high availability yourself, and the version on the VM must be the same as the source or newer.
RouteTargetDowntimePractical sizeMain prerequisites
Native backup to URL and RESTORE FROM URLManaged InstanceOffline: backup, upload and restoreUp to a few TB, as far as the window allowsBackup to URL with a SAS from SQL Server 2016 (older: back up to disk and upload); no FILESTREAM; TDE certificate on the instance first
Log Replay Service (LRS)Managed InstanceMinimal: minutesAny size the instance holds; one job runs at most 30 daysSQL Server 2008 or later, full recovery model, backups in one flat folder per database, SAS with read and list only or a managed identity
Managed Instance linkManaged InstanceNear-zero: a planned failoverAny size the instance holdsSQL Server 2016 SP3 or later with the required update, Enterprise, Standard or Developer, availability groups feature, VPN or ExpressRoute with ports 5022 and 11000–11999
Azure DMS, onlineManaged Instance (also a VM)Minimal: minutesLarge databases; DMS restores existing backupsFull and log backups on a network share (with a self-hosted integration runtime) or in Blob Storage; sysadmin on the source
Azure DMS, offlineAzure SQL Database, HyperscaleOffline: the whole copyUp to some hundreds of GB; slow with thousands of tablesSelf-hosted integration runtime, target database created, schema migrated first (DMS can do it)
.bacpac with SqlPackageAzure SQL Database, HyperscaleOffline: export and importUp to roughly 100–200 GBNo writes during the export; only objects Azure SQL Database supports
Transactional replicationAzure SQL Database, Hyperscale (also Managed Instance)Minimal: minutesLarge databases, if replication keeps up with the change ratePublisher and distributor SQL Server 2016 or later, a primary key on every published table, push subscription
Backup and restore, log shipping, availability groupSQL Server on an Azure VMOffline to near-zeroAny sizeAs on-premises; the same or a newer SQL Server version on the VM

The guide SQL Server to Azure SQL: Database or Managed Instance on this site compares the targets in more detail, and the guide on SQL Server features in a migration lists, per feature, what replaces it. The guide on migration routes and downtime explains the three downtime classes used in the table.

Assess the database and size the target

Before anything is copied, check what the target does not support and how large it must be. Microsoft changed the tooling in 2025 and 2026, so older articles often point to tools that no longer exist. The current options:

  • SQL Server Management Studio 22 or later: add the Hybrid and Migration workload in the Visual Studio Installer, right-click the instance and choose Migrate SQL Server. Run Assessment compares Azure SQL Database, Azure SQL Managed Instance and SQL Server on Azure VMs: readiness (Ready, or Ready with conditions with the affected objects), a minimum configuration with service tier, vCores and storage, and an estimated monthly price. From there you can create the target and start a migration with the Managed Instance link, backup and restore, or Azure DMS. An assessment only needs read permissions such as VIEW SERVER STATE and VIEW ANY DEFINITION; starting a migration needs sysadmin.
  • SQL Server enabled by Azure Arc: once an instance is connected to Azure Arc, Azure runs a readiness assessment every week. The Database migration pane of the instance in the Azure portal then migrates databases to a managed instance with the Managed Instance link or Log Replay Service, and monitors the cutover.
  • Azure Migrate: for whole data centres. An appliance discovers the SQL Server instances and Azure Migrate assesses them at scale, with target recommendations, sizing and monthly estimates.
  • Azure DMS: still available, through the Azure portal, PowerShell (Az.DataMigration) and Azure CLI (az datamigration). It moves data; it does not assess.
  • Retired: Azure Data Studio and its Azure SQL migration extension were retired on 28 February 2026, and Data Migration Assistant in July 2025. The classic version of Azure DMS has been retired as well. Do not start a new project with these tools.

Size from measurements, not from the current hardware: collect CPU, memory, IOPS and log throughput over a representative period, month-end included. On a managed instance in General Purpose, the throughput per data file depends on the file size, and the log write rate has a fixed ceiling per tier: batch jobs that write a lot of log are the usual surprise. Treat the recommendation as a minimum and keep headroom for the first weeks.

The assessment tools list findings, not the rework they mean. The free MigrateMyDatabase scan shows per target which SQL Server features your database uses that the target lacks or limits: SQL Server Agent jobs where Azure SQL Database has no Agent, CLR assemblies, Service Broker, cross-database queries, linked servers, FILESTREAM, Windows logins and more, each with what usually replaces it. The read-only script collects structure only, and the analysis runs in your browser.

Route 1: native backup to URL and restore on a managed instance

The simplest route to a managed instance: a full backup to Azure Blob Storage, then a restore on the instance. The application is stopped during the backup, the upload and the restore, so this is an offline route. It suits databases up to a few hundred gigabytes, or larger ones when the window allows it. The steps:

  • 1. Storage. Create a storage account with a private blob container in the same region as the managed instance, used for backup files only. Shared Key authorisation must stay enabled on the account for backup to URL with a SAS.
  • 2. Credential on the source. On SQL Server 2016 and later, create a credential named exactly after the container URL, with a SAS token that allows read, write, list and delete, without the leading question mark. SQL Server 2019 and older accept SAS tokens of at most 256 characters. SQL Server 2014 and older cannot write block blobs with a SAS: back up to disk and upload the files with AzCopy or Azure Storage Explorer.
  • 3. Backup. Stop the application and take a full backup WITH COPY_ONLY, CHECKSUM, COMPRESSION. COPY_ONLY leaves the differential base of your regular backups untouched. One blob holds about 195 GB, so stripe larger backups over several URLs (at most 64) with MAXTRANSFERSIZE = 4194304 and BLOCKSIZE = 65536.
  • 4. TDE. If the database is encrypted with TDE, upload the certificate with its private key to the managed instance before the restore (PowerShell Add-AzSqlManagedInstanceTransparentDataEncryptionCertificate with the certificate exported as a .pfx), or the instance cannot read the backup.
  • 5. Credential on the managed instance. A SAS with read and list is enough, or the managed identity of the instance with the role Storage Blob Data Reader on the storage account. Storage account keys are not supported.
  • 6. Restore. Test the access with RESTORE HEADERONLY or RESTORE FILELISTONLY, then run RESTORE DATABASE ... FROM URL with every stripe. A managed instance accepts no WITH options: no MOVE, REPLACE, STATS or NORECOVERY.
  • 7. Follow and check. The restore is asynchronous and continues if your session drops; follow it in sys.dm_operation_status (during some phases a GUID shows instead of the database name). Then run DBCC CHECKDB, compare row counts and recreate the server objects described further on.
On the source SQL Server
-- On the source SQL Server (2016 or later). Credential name = container URL, no trailing slash.
-- SAS token for the container with read, write, list and delete rights, without the leading '?'.
CREATE CREDENTIAL [https://<account>.blob.core.windows.net/<container>]
    WITH IDENTITY = 'SHARED ACCESS SIGNATURE',
    SECRET = '<SAS token>';

-- Copy-only full backup, striped over several blobs
-- (one blob holds about 195 GB, at most 64 stripes)
BACKUP DATABASE [Sales]
    TO URL = 'https://<account>.blob.core.windows.net/<container>/Sales_1.bak',
       URL = 'https://<account>.blob.core.windows.net/<container>/Sales_2.bak',
       URL = 'https://<account>.blob.core.windows.net/<container>/Sales_3.bak'
    WITH COPY_ONLY, CHECKSUM, COMPRESSION,
         MAXTRANSFERSIZE = 4194304, BLOCKSIZE = 65536, STATS = 10;
On the managed instance
-- On the managed instance: credential with a SAS (read and list are enough) ...
CREATE CREDENTIAL [https://<account>.blob.core.windows.net/<container>]
    WITH IDENTITY = 'SHARED ACCESS SIGNATURE',
    SECRET = '<SAS token>';
-- ... or with the managed identity of the instance
-- (role Storage Blob Data Reader on the storage account):
-- CREATE CREDENTIAL [https://<account>.blob.core.windows.net/<container>]
--     WITH IDENTITY = 'MANAGED IDENTITY';

-- Test the access, then restore. No WITH options on a managed instance:
-- no MOVE, REPLACE, STATS or NORECOVERY; the instance places the files itself.
RESTORE HEADERONLY FROM
    URL = 'https://<account>.blob.core.windows.net/<container>/Sales_1.bak',
    URL = 'https://<account>.blob.core.windows.net/<container>/Sales_2.bak',
    URL = 'https://<account>.blob.core.windows.net/<container>/Sales_3.bak';

RESTORE DATABASE [Sales] FROM
    URL = 'https://<account>.blob.core.windows.net/<container>/Sales_1.bak',
    URL = 'https://<account>.blob.core.windows.net/<container>/Sales_2.bak',
    URL = 'https://<account>.blob.core.windows.net/<container>/Sales_3.bak';

-- The restore goes on even if your session drops: follow it here
SELECT major_resource_id AS database_name, operation, state_desc,
       percent_complete, error_desc, start_time, last_modify_time
FROM sys.dm_operation_status
ORDER BY start_time DESC;

What a managed instance refuses to restore: a backup with FILESTREAM or FileTable data, a database with more than one log file, a .bak file that contains several backup sets (always write each backup to a new file), and in-memory OLTP objects on General Purpose. A General Purpose instance has a limit of 280 database files per instance. The restored database always runs in the full recovery model, and Service Broker keeps the state it had in the backup: enable it on the source first if you need it.

The version matters too. A backup can only be restored on an instance whose update policy is at least the SQL Server version of the source; for example, plan the SQL Server 2025 or Always-up-to-date policy for a database from SQL Server 2025. Check the current restore limits per service tier before you size the instance.

Route 2: Log Replay Service to a managed instance

Log Replay Service (LRS) is a free service built on log shipping. You put full, differential and log backups in Blob Storage, and the managed instance keeps restoring them while the source stays in use. The switch only takes the last log backup and its restore, usually minutes. LRS works with SQL Server 2008 and later, and also with sources such as Amazon RDS for SQL Server and Cloud SQL for SQL Server. With an Arc-enabled SQL Server, the Azure portal runs the same mechanism as Migrate using log shipping.

LRS has two modes. In autocomplete mode the whole backup chain is in the folder before you start, you name the last file, and LRS completes by itself after restoring it: suitable for a database that no longer changes. In continuous mode LRS keeps scanning the folder and restores every new differential and log backup until you start the cutover yourself: the mode for a database in use. The steps for continuous mode:

  • 1. Prerequisites. The database uses the full recovery model; Azure CLI 2.42.0 or later or the Az.Sql module 4.0.0 or later; the role SQL Managed Instance Contributor. No database with the same name may exist on the instance. If the database uses accelerated database recovery, set its persistent version store to PRIMARY.
  • 2. One folder per database. All backups of one database go into one folder of the container, in a flat structure without subfolders, and nothing else goes there. The container and folder names must not contain the word backup, which is reserved.
  • 3. Backups with CHECKSUM. Take the full backup and then the differential and log backups WITH CHECKSUM and compression. Without CHECKSUM the restore is slower and corruption may go unnoticed. Split large full backups over several files.
  • 4. Access. A SAS for the whole container with Read and List only (with more rights LRS refuses to start, and SAS tokens based on a stored access policy are not supported), or the managed identity of the instance with Storage Blob Data Reader. Not both on the same storage account.
  • 5. Start. Start LRS separately for each database, pointing at its folder, and follow it with az sql midb log-replay show.
  • 6. Keep the chain intact. Keep taking log backups into the folder. A log backup that another job writes elsewhere, for example a maintenance plan or a backup tool, breaks the chain for LRS unless that file is uploaded too: pause those jobs or point them to the folder.
  • 7. Cutover. Stop the application, take the last log backup (optionally WITH NORECOVERY, which keeps the source unchanged as a way back), wait until show reports it restored and run complete with the name of that file. The database comes online for reading and writing; after that the migration is final and accepts no more backups.
Backups on the source
-- On the source: FULL recovery model; all backups of one database in ONE flat folder.
-- Container and folder names must not contain the word "backup".
BACKUP DATABASE [Sales]
    TO URL = 'https://<account>.blob.core.windows.net/<container>/Sales/Sales_full_1.bak',
       URL = 'https://<account>.blob.core.windows.net/<container>/Sales/Sales_full_2.bak'
    WITH CHECKSUM, COMPRESSION, MAXTRANSFERSIZE = 4194304, BLOCKSIZE = 65536;

-- Optional: a differential shortly before the switch shortens the replay
BACKUP DATABASE [Sales]
    TO URL = 'https://<account>.blob.core.windows.net/<container>/Sales/Sales_diff_1.bak'
    WITH DIFFERENTIAL, CHECKSUM, COMPRESSION;

-- Every log backup goes to the same folder, in order, until the switch
BACKUP LOG [Sales]
    TO URL = 'https://<account>.blob.core.windows.net/<container>/Sales/Sales_log_0001.trn'
    WITH CHECKSUM, COMPRESSION;

-- At the switch: the last log backup. NORECOVERY leaves the source in RESTORING (no more writes);
-- RESTORE DATABASE [Sales] WITH RECOVERY brings it back if you roll back.
BACKUP LOG [Sales]
    TO URL = 'https://<account>.blob.core.windows.net/<container>/Sales/Sales_log_0042.trn'
    WITH CHECKSUM, COMPRESSION, NORECOVERY;
Azure CLI
# Continuous mode. SAS for the container with READ and LIST only (more rights: LRS does not start).
az sql midb log-replay start -g <resource-group> --mi <managed-instance> -n Sales \
    --storage-uri "https://<account>.blob.core.windows.net/<container>/Sales" \
    --storage-sas "<SAS token without the leading ?>"

# Progress: restored files and the state of the job
az sql midb log-replay show -g <resource-group> --mi <managed-instance> -n Sales

# Cutover, after the last log backup has been uploaded and restored
az sql midb log-replay complete -g <resource-group> --mi <managed-instance> -n Sales \
    --last-backup-name "Sales_log_0042.trn"

# Autocomplete mode instead: the whole chain is already in the folder
# az sql midb log-replay start ... -a --last-bn "Sales_log_0042.trn"

# Cancel: deletes the database that is being restored on the instance
az sql midb log-replay stop -g <resource-group> --mi <managed-instance> -n Sales
PowerShell with a managed identity
# Az.Sql: the same with the managed identity of the instance instead of a SAS
# (role Storage Blob Data Reader; -Collation = collation of the source database)
Start-AzSqlInstanceDatabaseLogReplay -ResourceGroupName "<resource-group>" `
    -InstanceName "<managed-instance>" -Name "Sales" `
    -Collation "SQL_Latin1_General_CP1_CI_AS" `
    -StorageContainerUri "https://<account>.blob.core.windows.net/<container>/Sales" `
    -StorageContainerIdentity ManagedIdentity

Get-AzSqlInstanceDatabaseLogReplay -ResourceGroupName "<resource-group>" `
    -InstanceName "<managed-instance>" -Name "Sales"

Complete-AzSqlInstanceDatabaseLogReplay -ResourceGroupName "<resource-group>" `
    -InstanceName "<managed-instance>" -Name "Sales" -LastBackupName "Sales_log_0042.trn"

Plan around these limits. One LRS job runs at most 30 days and is then cancelled. The database cannot be read on the instance until the cutover. System updates of the instance pause LRS on General Purpose and restart it from the beginning on Business Critical, so set a maintenance window outside the migration period. On Business Critical the database also stays unavailable after the cutover until it has been seeded to the secondary replicas, which can take hours for a large database: migrate to General Purpose first and change the tier online afterwards, or use the Managed Instance link. Stopping LRS with stop deletes the database being restored.

The Managed Instance link creates a distributed availability group between SQL Server and the managed instance. The database on the instance is a readable secondary that stays in sync in near real time, for days or months if needed, and the switch is a planned failover. It has the shortest switch of all Azure routes and is the only online route to Business Critical without waiting for seeding after the switch. The prerequisites:

RequirementWhat is needed
SQL Server versionSQL Server 2016 SP3 with the SQL Server 2016 Azure Connect pack (13.0.7000.253); SQL Server 2017 CU31 with the Azure Connect pack (14.0.3490.10); SQL Server 2019 CU20 (15.0.4312.2); SQL Server 2022 and SQL Server 2025 from RTM. SQL Server 2014 and older are not supported.
Edition and operating systemEnterprise, Standard or Developer. Windows Server (SQL Server 2016 only on Windows, with extra cluster steps to enable availability groups), or Linux from SQL Server 2017. Not on Windows 10 or 11.
Instance settingsThe Always On availability groups feature enabled (SQL Server Configuration Manager, then a restart), a database master key in master, and the recommended startup trace flags -T1800 and -T9567.
DatabaseFull recovery model, at least one full backup, exactly one log file, no FILESTREAM or FileTable; In-Memory OLTP only to Business Critical. With TDE: a customer-managed key in Azure Key Vault on the instance and the protector moved before the link is created.
NetworkVPN or ExpressRoute (from an Azure VM: the same or a peered virtual network); the link only uses the VNet-local endpoint of the instance. Instance subnet: inbound TCP 5022 and 11000–11999 from SQL Server, outbound 5022 to SQL Server. SQL Server side: inbound 5022 from the instance subnet, outbound 5022 and 11000–11999 to it.
CertificatesAuthentication between the two is certificate-based only, never Windows authentication. The SSMS wizard creates the endpoint certificate on SQL Server and exchanges the public keys with the instance.
Update policy of the instanceAt least the source version for the cutover. For a way back to SQL Server: the SQL Server 2022 policy for SQL Server 2022, the SQL Server 2025 policy for SQL Server 2025. With Always-up-to-date there is no way back.
  • 1. Prepare SQL Server. Install the required update, enable availability groups, create the master key, add the trace flags and restart. Set the database to the full recovery model and take a full backup.
  • 2. Open and test the network. Open the ports in every firewall on the path, including the Windows firewall and the network security group of the instance subnet. Test both directions in SSMS: right-click the database, Azure SQL Managed Instance link, Test Connection (under Tasks in recent SSMS versions).
  • 3. Create the instance with enough storage, the right service tier and the update policy that matches your plan for a way back.
  • 4. Create the link. In the latest SSMS, right-click the database, Azure SQL Managed Instance link, Replicate database. The wizard signs in to Azure, creates the availability group, the distributed availability group and the certificates, and starts seeding. With an Arc-enabled SQL Server the Azure portal offers the same as Migrate using real-time replication.
  • 5. Wait and test. Wait until seeding has finished and the link is healthy, then test reports and read-only queries on the replica. Follow the lag with the query below.
  • 6. Switch. Stop the application, check that the lag is zero, and in SSMS choose Failover database with Planned failover. For a migration, tick the option to remove the link after the failover. Keep the link only on SQL Server 2022 or 2025 with a matching update policy, if you want a way back; when you remove it later, first wait for the first automatic full backup on the instance.
  • 7. Reconnect the application to the instance endpoint.
Prepare SQL Server
-- On SQL Server: version and update level, availability groups feature, trace flags
SELECT @@VERSION AS version,
       SERVERPROPERTY('IsHadrEnabled') AS availability_groups_enabled;  -- 1 = enabled
DBCC TRACESTATUS;                                                       -- expect 1800 and 9567

-- Database master key in master (protects the certificates of the link)
USE master;
IF NOT EXISTS (SELECT 1 FROM sys.symmetric_keys WHERE name = '##MS_DatabaseMasterKey##')
    CREATE MASTER KEY ENCRYPTION BY PASSWORD = '<strong password>';

-- The database: FULL recovery model, exactly one log file, at least one full backup
ALTER DATABASE [Sales] SET RECOVERY FULL;
SELECT type_desc, name, physical_name FROM [Sales].sys.database_files;
BACKUP DATABASE [Sales] TO DISK = N'<path>\Sales_full.bak' WITH CHECKSUM, COMPRESSION;
Lag of the link
-- On SQL Server and on the managed instance: state and lag of the link
DECLARE @link_name sysname = N'<link name>';  -- name of the distributed availability group
SELECT ag.name                           AS link_name,
       ars1.role_desc                    AS local_role,
       ars2.connected_state_desc         AS connected_state,
       ars2.synchronization_health_desc  AS sync_health,
       drs.secondary_lag_seconds         AS lag_seconds
FROM sys.availability_groups AS ag
JOIN sys.dm_hadr_availability_replica_states AS ars1 ON ag.group_id = ars1.group_id
JOIN sys.dm_hadr_availability_replica_states AS ars2 ON ag.group_id = ars2.group_id
JOIN sys.dm_hadr_database_replica_states AS drs ON ars2.replica_id = drs.replica_id
WHERE ag.is_distributed = 1 AND ag.name = @link_name
  AND ars1.is_local = 1 AND ars2.is_local = 0;

A link replicates one database in single-database mode; several databases need several links, best migrated about eight at a time per instance. From SQL Server 2022 CU28 and SQL Server 2025 CU11, Enterprise and Developer can also extend an existing availability group with all its databases in one link. A managed instance with a link cannot be in a failover group. Distributed transactions with SQL Server, CDC and log shipping settings, and the role of a replication publisher do not carry over: reconfigure them after the switch.

Route 4: Azure Database Migration Service

Azure DMS runs a migration from the Azure portal, PowerShell or Azure CLI, and works differently per target:

Managed Instance, online or offline: DMS does not take backups. It restores existing full and log backups from an SMB network share or from Blob Storage, and in online mode it keeps restoring new log backups until you start the cutover. Backups on a share need a self-hosted integration runtime on a Windows machine that can reach the source and the share (outbound 443 to Azure, 445 to the share); DMS uploads them to a storage account in the same region. Backups that are already in Blob Storage need no integration runtime. Each backup must be in its own file: several backups appended to one file are not supported, and the container must hold backup files only.

SQL Server on an Azure VM, online or offline: the same mechanism; the VM must be registered with the SQL IaaS Agent extension in full mode.

Azure SQL Database, offline only: a logical copy, table by table, through Azure Data Factory pipelines that run on the self-hosted integration runtime; no backups are involved. The target database must exist. DMS can first create the missing schema (tables, indexes, views, procedures, functions, types, users and more) with Migrate missing schema, or you deploy it yourself with a SQL database project or SqlPackage. The application is down from the start of the copy until the end. The steps in the portal:

  • 1. Prepare. Register the resource provider Microsoft.DataMigration in the subscription and create the target. For Azure SQL Database, give the migration login the roles it needs on the target (db_owner, and for schema migration the server roles ##MS_DatabaseManager##, ##MS_DatabaseConnector##, ##MS_DefinitionReader## and ##MS_LoginManager##).
  • 2. Create the service. In the portal, Azure Database Migration Service, Create: choose SQL Server as source and the target type, then the subscription, resource group, region and name.
  • 3. Integration runtime, where needed. Under Settings, Integration runtime, download the self-hosted integration runtime, install it close to the source and register it with one of the authentication keys. Schema migration to Azure SQL Database needs version 5.37 or later. The machine does the copying, so give it enough CPU and memory.
  • 4. New migration. Choose source, target and mode, connect to the source (sysadmin or CONTROL SERVER for a managed instance or VM; db_datareader and VIEW ANY DEFINITION for Azure SQL Database, db_owner for schema migration), select the databases and then the backup location, or the tables and the schema option.
  • 5. Monitor. Under Monitor migrations: for a managed instance the restored backups per database, for Azure SQL Database the state per table (Preparing for copy, Copying, Rebuilding indexes, Succeeded).
  • 6. Cutover (managed instance, online). Stop the application, take a last log backup into the same location, wait until DMS has restored it, then start the cutover in the portal or with az datamigration sql-managed-instance cutover.
Not migrated or limitedWhat to do
Logins and server rolesRecreate them with the same SID before the switch (see what never moves).
SQL Server Agent jobs, linked servers, Database Mail, server settingsScript and recreate them separately, or replace them on Azure SQL Database.
TDE-encrypted databasesMove the certificate to the managed instance or VM before the migration, and check the current DMS documentation for your scenario.
Azure SQL Database: computed columnsListed by Microsoft as not migrated: check them in the target schema.
Azure SQL Database: NULL in a column with a defaultArrives as the default value instead of NULL: compare such columns before the switch.
Azure SQL Database: other limitsTables with large LOB columns can time out; table names with double-byte characters are not supported; empty tables are skipped; with CDC enabled on the source, disable it before a schema migration.
Azure CLI, managed instance online
# Azure CLI: create the service and start an online migration to a managed instance.
# The backups are already in Blob Storage, so no self-hosted integration runtime is needed.
az datamigration sql-service create --resource-group <resource-group> \
    --sql-migration-service-name <dms-name> --location <region>

az datamigration sql-managed-instance create \
    --resource-group <resource-group> --managed-instance-name <managed-instance> \
    --source-database-name Sales --target-db-name Sales \
    --source-location '{"AzureBlob":{"storageAccountResourceId":"<storage account resource id>","accountKey":"<key>","blobContainerName":"<container>"}}' \
    --migration-service "<resource id of the DMS service>" \
    --scope "<resource id of the managed instance>" \
    --source-sql-connection authentication="SqlAuthentication" data-source="<source server>" user-name="<login>" password="<password>"

# Follow the restores, then cut over after the last log backup has been restored
az datamigration sql-managed-instance show --resource-group <resource-group> \
    --managed-instance-name <managed-instance> --target-db-name Sales --expand MigrationStatusDetails

az datamigration sql-managed-instance cutover --resource-group <resource-group> \
    --managed-instance-name <managed-instance> --target-db-name Sales \
    --migration-operation-id <migrationOperationId from the show command>

DMS to Azure SQL Database is limited by Azure Data Factory: each table adds start-up time, so databases with thousands of small tables are slow, and the speed depends on the size of the target and of the integration runtime machine. For a managed instance, Log Replay Service and the Managed Instance link do the same work with fewer moving parts; DMS is most useful when you want one service for many databases or for a VM target.

Route 5: a .bacpac with SqlPackage to Azure SQL Database

A .bacpac holds the schema and the data of one database in one file. SqlPackage exports it from SQL Server and imports it into Azure SQL Database, which creates the database. It is simple, but it is a logical copy: every row is read and inserted again, and every index is built again. The steps:

  • 1. Install the latest SqlPackage on Windows, macOS or Linux, for example as a .NET tool with dotnet tool install -g microsoft.sqlpackage. Run it close to the data: the export near the source, the import preferably from an Azure VM in the region of the target.
  • 2. Make the export consistent. An export is not a transactionally consistent snapshot. Stop the application for the whole export, or export from a restored copy of a backup.
  • 3. Remove what Azure SQL Database refuses. Windows users, references to other databases (three-part names), and features that Azure SQL Database lacks make the export or the import fail. Fix or remove them first; the scan lists them per object.
  • 4. Size the target for the import. Name the edition and service objective in the import (/p:DatabaseEdition, /p:DatabaseServiceObjective), or create the database in a larger tier, and scale down after the import. Importing into a small tier is very slow. For Hyperscale use DatabaseEdition=Hyperscale.
  • 5. Export and import with the commands below. For a large export, point /p:TempDirectoryForTableData to a disk with enough space.
  • 6. Check the row counts and the code objects, update statistics, and recreate the logins (see further on). The imported database keeps the compatibility level of the source.
SqlPackage (PowerShell)
# Export from SQL Server (no writes during the export: stop the application or use a restored copy)
SqlPackage /Action:Export /SourceServerName:"<source-server>" /SourceDatabaseName:"Sales" `
    /SourceTrustServerCertificate:True /TargetFile:"D:\export\Sales.bacpac" `
    /p:TempDirectoryForTableData="D:\export\tmp"

# Import into Azure SQL Database: choose the tier at once, scale down after the import
SqlPackage /Action:Import /SourceFile:"D:\export\Sales.bacpac" `
    /TargetServerName:"<server>.database.windows.net" /TargetDatabaseName:"Sales" `
    /TargetUser:"<admin>" /TargetPassword:"<password>" `
    /p:DatabaseEdition=GeneralPurpose /p:DatabaseServiceObjective=GP_Gen5_8

# Hyperscale instead:          /p:DatabaseEdition=Hyperscale /p:DatabaseServiceObjective=HS_Gen5_8
# Microsoft Entra ID instead:  /UniversalAuthentication:True /TenantId:"<tenant>"

When not to use it: above roughly 100–200 GB, when the window is short, or when writes cannot stop for the whole export and import. The import service in the Azure portal has its own limits: .bacpac files over 150 GB can fail there, its machines have 450 GB of local disk, and storage behind a firewall is not supported. Use SqlPackage instead; importing into an elastic pool also only works with SqlPackage. For larger databases choose Azure DMS or transactional replication.

Route 6: transactional replication to Azure SQL Database

For Azure SQL Database, transactional replication is the way to keep the switch to minutes. The database in Azure becomes a push subscriber of a publication on your SQL Server: it receives a snapshot first and then every change. The switch: stop writes, wait until the latency is zero, reconnect the application. The requirements and steps:

  • Versions and roles. The publisher and the distributor run SQL Server 2016 or later, on-premises, on an Azure VM or on a managed instance. Azure SQL Database can only be a push subscriber; the distribution database and the agents cannot be placed there.
  • Primary keys. Every published table needs a primary key. Tables without one have to get one first, or move another way.
  • Authentication. The distribution agent connects with a SQL login, or with Microsoft Entra ID through a service principal or an Arc-enabled SQL Server. Replication is configured and monitored on SQL Server (SSMS or T-SQL), not in the Azure portal.
  • 1. Configure the distributor on the source or on a separate server.
  • 2. Create the publication with an article per table. The snapshot does not carry everything: partitioning, filtered, spatial, XML and full-text indexes, data compression, permissions and extended properties stay behind, and procedures, views, functions and users are not part of a table publication. Deploy them from a schema script, before or after the snapshot, and set each article's pre-creation command (pre_creation_cmd) to match your choice.
  • 3. Add the push subscription to <server>.database.windows.net and the target database, with subscriber type 0.
  • 4. Initialise and follow. The snapshot agent creates the snapshot, the distribution agent applies it and then the changes. Follow the latency in Replication Monitor or with tracer tokens.
  • 5. Switch. Stop writes, wait for a tracer token to arrive, compare row counts, reseed identity columns where needed (DBCC CHECKIDENT), reconnect the application, then remove the subscription and the publication.
Check and outline on the publisher
-- Tables without a primary key cannot be published: list them first
SELECT s.name AS schema_name, t.name AS table_name
FROM sys.tables AS t
JOIN sys.schemas AS s ON s.schema_id = t.schema_id
WHERE t.is_ms_shipped = 0
  AND OBJECTPROPERTY(t.object_id, 'TableHasPrimaryKey') = 0
ORDER BY s.name, t.name;

-- Outline on the publisher, after the distributor has been configured (one article per table)
EXEC sp_replicationdboption @dbname = N'Sales', @optname = N'publish', @value = N'true';
EXEC sp_addpublication @publication = N'Sales_to_Azure', @status = N'active',
     @allow_push = N'true', @repl_freq = N'continuous';
EXEC sp_addpublication_snapshot @publication = N'Sales_to_Azure';
EXEC sp_addarticle @publication = N'Sales_to_Azure', @article = N'Orders',
     @source_owner = N'dbo', @source_object = N'Orders';
EXEC sp_addsubscription @publication = N'Sales_to_Azure',
     @subscriber = N'<server>.database.windows.net', @destination_db = N'Sales',
     @subscription_type = N'Push', @subscriber_type = 0;
EXEC sp_addpushsubscription_agent @publication = N'Sales_to_Azure',
     @subscriber = N'<server>.database.windows.net', @subscriber_db = N'Sales',
     @subscriber_security_mode = 0,  -- SQL authentication
     @subscriber_login = N'<login>', @subscriber_password = N'<password>';

Replication only works if it keeps up with the change rate of the source; test with production volumes. After the switch there is no reverse stream: Azure SQL Database cannot be a publisher, so writes made in Azure do not flow back to SQL Server.

What never moves with the database

Every route above moves the user database only. What lives in master and msdb stays behind and has to be scripted and recreated, preferably before the switch:

ObjectManaged Instance and VMAzure SQL Database
Logins and SIDsRecreate SQL logins with the same SID and password hash (CREATE LOGIN ... HASHED, SID = ... or dbatools Copy-DbaLogin). Windows logins become Microsoft Entra logins on a managed instance.Logins in master with the same SID and a new password (no hashed passwords), or contained database users. Windows logins become Microsoft Entra users.
SQL Server Agent jobsScript them (SSMS or Copy-DbaAgentJob). On a managed instance CmdExec steps, proxies and alerts are not supported, and schedules follow the time zone of the instance (UTC unless another one was chosen at creation).No Agent: Elastic Jobs, Azure Automation or Logic Apps.
Linked serverssp_addlinkedserver and sp_addlinkedsrvlogin, or Copy-DbaLinkedServer. A managed instance only links to SQL Server and Azure SQL, with SQL or Entra authentication.None: elastic query, Azure Data Factory or the application.
Database MailRecreate the profile and account (Copy-DbaDbMail). On a managed instance, Agent notifications need the profile AzureManagedInstance_dbmail_profile, and attachments are not possible.None: Logic Apps or Azure Communication Services.
Server settingsCompare sp_configure, max server memory, MAXDOP, cost threshold and trace flags. On a managed instance part of them is fixed by the service.Database scoped configurations (MAXDOP and others); there are no server settings.
TDE certificatesVM: back up the certificate with its private key and create it on the VM before the restore. Managed instance: upload it with Add-AzSqlManagedInstanceTransparentDataEncryptionCertificate, or use a customer-managed key in Azure Key Vault for the link.Not needed: a .bacpac, DMS and replication copy decrypted data, and Azure encrypts the new database with its own TDE by default.
Other server objectsCredentials, server triggers, server audits (to Blob Storage on a managed instance), the SSIS catalog and maintenance plans.Server triggers become auditing or Microsoft Defender; SSIS runs in Azure Data Factory.
Logins with the same SID
-- On the source: SQL logins with SID and password hash
SELECT name,
       CONVERT(varchar(100), sid, 1)                                  AS sid,
       CONVERT(varchar(514), LOGINPROPERTY(name, 'PasswordHash'), 1) AS password_hash,
       default_database_name, is_disabled
FROM sys.sql_logins
WHERE name NOT LIKE '##%' AND name <> 'sa';

-- Managed instance or VM: same SID and the same password (hash)
CREATE LOGIN [app_sales] WITH PASSWORD = <password_hash> HASHED, SID = <sid>;

-- Azure SQL Database (in master): same SID, new password; hashed passwords are not accepted
CREATE LOGIN [app_sales] WITH PASSWORD = '<new strong password>', SID = <sid>;

-- Managed instance or VM, in the migrated database: users without a matching login
SELECT dp.name AS orphaned_user
FROM sys.database_principals AS dp
LEFT JOIN sys.server_principals AS sp ON sp.sid = dp.sid
WHERE dp.type = 'S' AND dp.authentication_type = 1 AND sp.sid IS NULL;
ALTER USER [app_sales] WITH LOGIN = [app_sales];
dbatools
# dbatools (PowerShell): logins with SID and password, jobs, linked servers, Database Mail
Copy-DbaLogin        -Source <old-server> -Destination <new-instance> -ExcludeSystemLogins
Copy-DbaAgentJob     -Source <old-server> -Destination <new-instance>
Copy-DbaLinkedServer -Source <old-server> -Destination <new-instance>
Copy-DbaDbMail       -Source <old-server> -Destination <new-instance>

Do the logins first: the users inside the database arrive with the database, and a login with the same SID makes them work at once. With a different SID the user is orphaned, and ALTER USER ... WITH LOGIN maps it again. Custom error messages from sp_addmessage are not available on a managed instance or Azure SQL Database: use THROW with the message text. The SQL Server Agent guide on this site covers the jobs in more detail.

Compatibility level, statistics and Query Store after the move

A restored or imported database keeps its compatibility level; a managed instance accepts levels from 100 upwards. Changing the engine and the compatibility level at the same time makes it hard to tell which change made a query slower. A safe order:

  • Keep the old level for the switch. The engine is new anyway; the level can follow later.
  • Update statistics after the switch, with sp_updatestats or a full scan on the most important tables.
  • Query Store on, in READ_WRITE mode. It is on by default in Azure SQL Database; a database restored on a managed instance or VM keeps the setting it had. Capture a baseline of a normal business cycle, month-end included.
  • Raise the level step by step, on a test copy first, then in production. Compare in Query Store (Regressed Queries) and fix regressions with plan forcing or Query Store hints; LEGACY_CARDINALITY_ESTIMATION as a database scoped configuration can serve as a temporary measure.
  • Check the database scoped configurations, such as MAXDOP: a server-wide setting from the old instance does not travel with the database.
  • Watch the limits of the tier: log write rate and IO per file on General Purpose, tempdb size, and the number of workers and sessions. Azure SQL Database also applies automatic plan correction (FORCE_LAST_GOOD_PLAN) by default.
Checks in the migrated database
-- Run in the migrated database
SELECT name, compatibility_level FROM sys.databases WHERE name = DB_NAME();

ALTER DATABASE CURRENT SET QUERY_STORE = ON (OPERATION_MODE = READ_WRITE);
SELECT actual_state_desc, readonly_reason FROM sys.database_query_store_options;

EXEC sp_updatestats;

SELECT name, value FROM sys.database_scoped_configurations
WHERE name IN (N'MAXDOP', N'LEGACY_CARDINALITY_ESTIMATION', N'PARAMETER_SNIFFING');

-- After a baseline of normal business: raise the level, on a test copy first
-- (150 = SQL Server 2019, 160 = 2022, 170 = 2025; use a level the target supports)
ALTER DATABASE CURRENT SET COMPATIBILITY_LEVEL = 160;

Cutover checklist and the way back

Write the switch down as a script with times and rehearse it at least once on a copy. A checklist that covers most moves to Azure:

  • Before the day: logins, jobs, linked servers, Database Mail and certificates created and tested on the target; firewall rules, private endpoints and DNS ready; new connection strings prepared (server name, encryption, authentication); monitoring and alerts on the target; automatic backups and their retention checked; the rehearsal timed; the rollback decision and its deadline agreed.
  • Freeze releases and schema changes until after the switch.
  • Stop writes: stop the application and the jobs on the source that write, and check that no sessions remain.
  • Complete the route: the last backup and restore, log-replay complete, the planned failover of the link, the DMS cutover, or replication latency at zero.
  • Validate: row counts per table, DBCC CHECKDB on a managed instance or VM, identity and sequence values after replication or DMS, and a smoke test of the main functions of the application.
  • Reconnect: switch connection strings or the DNS alias, enable the jobs on the target, disable them on the source.
  • Keep the source unchanged and read-only until the go-live is accepted.
  • Afterwards: check that the first automatic full backup has completed, then follow the plan for the compatibility level and Query Store.
RouteWay back before the switchWay back after the switch
Backup to URL, LRS, DMS to a managed instanceDrop the target database; the source was not changed.Back to the source, losing the writes made in Azure, or carry them back: a native backup of the instance restores on SQL Server 2022 or 2025 only when the update policy matches; otherwise a .bacpac or transactional replication from the instance.
Managed Instance linkRemove the link; SQL Server stays the primary.SQL Server 2022 or 2025 with a matching update policy and the link kept: a planned failover back. SQL Server 2016–2019 or Always-up-to-date: one-way, as the row above.
DMS offline or .bacpac to Azure SQL DatabaseDrop the target database.The source is unchanged; writes made in Azure are lost unless you copy them back (a .bacpac from Azure SQL Database imports into SQL Server).
Transactional replication to Azure SQL DatabaseRemove the subscription.As the row above: Azure SQL Database cannot publish back.
Log shipping or availability group to a VMStop the log shipping or remove the replica.Set up the reverse direction before the switch; going back is then a log restore or a failover.

A last log backup WITH NORECOVERY leaves the source in the RESTORING state: nobody can write to it by mistake, and RESTORE DATABASE ... WITH RECOVERY brings it back online if you roll back. Agree in advance until when going back is allowed; after that, problems are fixed on Azure.

Common errors and what to check

The errors that come up most in migrations to Azure, with the usual cause and where to look:

SymptomUsual causeCheck
RESTORE ... FROM URL fails with error 3201 or operating system error 86The credential does not match: the name is not the container URL, the SAS starts with a question mark, or the token has expiredDrop and recreate the credential: name = container URL without trailing slash, identity SHARED ACCESS SIGNATURE, secret without ?
BACKUP TO URL stops with a block or size errorOne blob holds about 195 GB (50,000 blocks)Stripe over more URLs with MAXTRANSFERSIZE = 4194304 and BLOCKSIZE = 65536
Restore on the managed instance is refusedFILESTREAM or FileTable, more than one log file, several backup sets in one file, in-memory objects on General Purpose, or a source newer than the update policyRESTORE HEADERONLY and FILELISTONLY; the database files on the source; the service tier and update policy of the instance
LRS does not startSAS with more than Read and List, a stored access policy, the word backup in the path, a database with the same name, or an expired SAS (time zones)Regenerate the SAS for the container, rename the folder, az sql mi op show for details
LRS stops restoring new log backupsThe log chain is broken: a log backup was written elsewhere, or files sit in a subfoldermsdb.dbo.backupset on the source for log backups to other locations; the folder structure
Long wait after the LRS cutover on Business CriticalThe database is seeded to the secondary replicasMigrate to General Purpose and change the tier online, or use the Managed Instance link
The Managed Instance link cannot be created or seeding never startsPorts 5022 or 11000–11999 blocked, availability groups feature off, no master key, database not in the full recovery model or without a full backupNetwork Checker in SSMS, SERVERPROPERTY('IsHadrEnabled'), the NSG of the instance subnet
Planned failover of the link times outThe secondary is behindThe lag query; stop the workload and wait until the lag is zero
.bacpac export fails with unsupported elementsWindows users, references to other databases or objects that Azure SQL Database does not supportThe error list of SqlPackage; the scan's findings for Azure SQL Database
SqlPackage reports that the certificate chain is not trustedRecent SqlPackage versions encrypt connections by default/SourceTrustServerCertificate:True, or a trusted certificate on the source
.bacpac import very slow or out of disk spaceA small target tier, or the portal import service (450 GB disk)Import with SqlPackage into a larger tier and scale down afterwards
Replication refuses a table, or error MSSQL_REPL20084 / 40532No primary key; or an unsupported SQL Server version or a login the subscriber does not acceptThe primary key query; SQL Server 2016 or later; a SQL login on the logical server
Login failed or empty permissions after the switchLogins missing, or recreated with a different SIDThe orphaned users query; ALTER USER ... WITH LOGIN
Agent job fails on the managed instanceCmdExec step, proxy, file share, or another Database Mail profile nameThe step types of the job; the profile AzureManagedInstance_dbmail_profile
Queries slower than beforeA new engine, old statistics, MAXDOP, or the limits of the tierQuery Store (Regressed Queries), sp_updatestats, database scoped configurations, resource waits

How the free scan and the full report help

The MigrateMyDatabase scan runs a read-only script on your SQL Server database that collects the structure, not the data. You paste the result into the page and choose Azure SQL Managed Instance, Azure SQL Database or Hyperscale as target. The analysis runs in your browser and shows which SQL Server features the target lacks or limits (SQL Server Agent on Azure SQL Database, CLR, Service Broker, cross-database queries, linked servers, FILESTREAM, Windows logins and more), which routes fit the downtime you can accept, and which tables stand in the way of an online route. Nothing is uploaded.

The full report adds the runbook for your own database: the chosen route with its commands filled in for your database and target, the order of the steps, the server objects to recreate, the cutover, the checks and the way back, reviewed by a migration specialist.

Questions

Can I restore a .bak file in Azure SQL Database?

No. Azure SQL Database accepts no native backups. Use a .bacpac with SqlPackage, Azure DMS in offline mode, or transactional replication with Azure SQL Database as subscriber. A managed instance and SQL Server on an Azure VM do restore native backups from Blob Storage.

Which route gives the shortest downtime to Azure?

To a managed instance, the Managed Instance link: the switch is a planned failover of a replica that is already in sync. Log Replay Service and Azure DMS in online mode need minutes for the last log backup. To Azure SQL Database, transactional replication gives minutes; the .bacpac and DMS offline need the application stopped for the whole copy.

Do I still need Azure Data Studio for the migration?

No. Azure Data Studio and its Azure SQL migration extension were retired on 28 February 2026. Assess with the Migrate SQL Server feature in SSMS 22 or later, with Azure Arc or with Azure Migrate, and run Azure DMS from the Azure portal, PowerShell or Azure CLI.

Can I go back to SQL Server after moving to a managed instance?

With the Managed Instance link, yes, from SQL Server 2022 or 2025 when the instance uses the matching update policy and the link is kept: going back is a planned failover. A native backup of the instance also restores on SQL Server 2022 or 2025 with a matching policy. From older versions, or with the Always-up-to-date policy, the way back is a .bacpac or transactional replication.

What is the difference between Log Replay Service and the Managed Instance link?

LRS restores backups from Blob Storage, works with SQL Server 2008 and later and every edition, and offers no readable copy until the cutover; a job runs at most 30 days. The link replicates through a distributed availability group, needs SQL Server 2016 SP3 or later with the required update and Enterprise, Standard or Developer edition, offers a readable replica, has no time limit and is the better choice for Business Critical.

Do logins and Agent jobs move with LRS, the link or DMS?

No. All these routes move the user database only. Logins, SQL Server Agent jobs, linked servers, Database Mail, server settings and TDE certificates have to be scripted and recreated. Recreate SQL logins with the same SID, so the users in the database keep working.

How large can a database be for a .bacpac?

There is no hard limit in SqlPackage, but a .bacpac reads and inserts every row and rebuilds every index, so above roughly 100 to 200 GB the export and import take many hours. The import service in the Azure portal can fail above 150 GB. For larger databases choose Azure DMS or transactional replication.

Read next

See which SQL Server features your database uses that the Azure target lacks, and which routes fit your downtime: run the free read-only scan and choose Managed Instance, Azure SQL Database or Hyperscale. Nothing leaves your browser.

Start the free scan