The short version
A SQL Server to Azure SQL Managed Instance migration uses one of four routes Microsoft documents: a native backup to Azure Blob storage restored with RESTORE FROM URL (simplest, downtime equals backup plus restore), Log Replay Service (LRS) for full, differential and log backups restored continuously from Blob storage (SQL Server 2008 to 2022, short cutover), the Managed Instance link for near real-time replication over a distributed availability group (SQL Server 2016 and later, the least downtime, the only true online route to Business Critical), and Azure Database Migration Service in the portal. Whatever the route, a database with FILESTREAM data or a second log file will not restore, and logins, Agent jobs, linked servers and mail profiles do not travel with the database.
Which route fits
Microsoft's migration overview frames the choice by three things: how many databases, how big, and how much downtime the business accepts. Its comparison, condensed:
| Route | Source versions | Downtime | Target readable during the move |
|---|---|---|---|
Native backup + RESTORE FROM URL |
2005 to 2022 | Full backup + upload + restore | Not until restored |
| Log Replay Service | 2008 to 2022 | Last log backup + cutover | No, database is RESTORING |
| Managed Instance link | 2016 and later | A planned failover | Yes, read-only |
| DMS / Azure Arc migration | Wraps LRS and the link | As the method it uses | As the method it uses |
Rules of thumb, all from the pages linked in each section: native restore for one or a few databases with a maintenance window; LRS when you can ship backups but need a short cutover, or when you cannot open network ports to Azure; the link when downtime must be minutes, the target is Business Critical, or you want the copy readable for weeks before cutover.
Native backup to URL and RESTORE FROM URL
Back up to a Blob container, create a credential on the managed instance, restore. On the instance, FROM URL is the only source, and RESTORE takes no WITH options at all: MOVE, REPLACE, STATS, NORECOVERY all fail (MI T-SQL differences). There are no differential or log restores by hand either, so this route moves one full backup and nothing after it. The credential name must match the container path with no trailing slash, and the SAS SECRET must not start with ? (restore quickstart).
Size matters on the source side. A single block blob holds about 195.3 GB (50,000 blocks of 4 MB), so stripe across up to 64 URLs with MAXTRANSFERSIZE = 4194304 and BLOCKSIZE = 65536 (backup to URL). SAS-based backup to block blobs needs SQL Server 2016 or later; 2012 SP1 CU2 to 2014 use the deprecated WITH CREDENTIAL syntax, and anything older backs up to disk and uploads the .bak (MI migration guide). A TDE database needs its certificate moved to the instance before the restore.
Log Replay Service (LRS)
LRS is log shipping run by Azure: you upload full, differential and log backups to one folder, start LRS with PowerShell or the Azure CLI, and it restores each new file it finds (LRS overview). It is the only way to restore differential backups on a managed instance. Autocomplete mode takes a finished backup chain; continuous mode keeps applying logs until you take the tail-log backup and run complete.
The requirements that trip people, all from Migrate with LRS: the database must be in the FULL recovery model; the SAS token must have Read and List only, and adding Write makes LRS fail to start; one flat folder per database, no subfolders; the container and folder names cannot contain backup; a single job runs at most 30 days. CHECKSUM is optional but without it the restore is slower and corruption can come along. On Business Critical, the database stays unavailable after cutover until three secondary replicas are seeded.
The Managed Instance link
The link builds a distributed availability group between SQL Server and the instance and replicates in near real time; the copy in Azure is readable while you wait (link overview). Cutover is a failover. It needs SQL Server 2016 or later (2016 on Windows Server only, with SP3 plus the Azure Connect pack), Enterprise, Standard or Developer edition, and a VPN or ExpressRoute path to the instance's VNet-local endpoint. In single-database mode each link carries one database. It does not replicate logins, Agent jobs or server objects, and it refuses databases with FILESTREAM or multiple log files. Failing back to SQL Server works only from SQL Server 2022 or 2025 with the matching update policy on the instance; from 2016 to 2019 the move is one way.
DMS and the Azure Arc migration
Azure DMS in the portal runs online and offline migrations to Managed Instance from backups in Blob storage or on an SMB share reached through a self-hosted integration runtime (MI migration guide). Its comparison table lists TDE support and login migration as "No". For a SQL Server enabled by Azure Arc, the portal's Database migration pane assesses the instance and drives either the link or LRS for you; failover cluster instances are not supported there.
What still fails on Managed Instance: the scan I ran
Managed Instance takes far more than Azure SQL Database, but not everything. I extended the offline scanner from the Azure SQL Database guide (and the per-target verdict in the comparison guide) into an MI-only check with two inputs: the scripted database, and the backup/restore script someone drafted for the move. Rules come from the MI T-SQL differences page, the LRS and link pages, and the trace-flag list: Managed Instance accepts only global trace flags 460, 2301, 2389, 2390, 2453, 2467, 7471, 8207, 9389, 10316 and 11024, and no session flags (DBCC TRACEON).
The sample is a made-up SQL Server 2016 logistics database, Fleet, written the way these usually look: a FILESTREAM column for scanned delivery notes, a memory-optimized table, a view over FleetArchive, SIMPLE recovery, a second log file, TDE with a certificate loaded from a file, two Windows logins, a startup procedure setting trace flags, an Excel linked server, a BULK INSERT from a file share, mail, an Agent job and alert. The backup script is the kind of first draft I see: a SAS secret pasted with its ?, a container called backups, restores with MOVE and NORECOVERY, and a log restore from disk.
Output, sqlglot 30.17.0 on Python 3.12.8. I dropped sqlglot's ten "Falling back to parsing as a 'Command'" warnings with 2>/dev/null; the rest is unedited:
$ python mi_ready.py fleet_scripted.sql fleet_backup_restore.sql 2>/dev/null
== fleet_scripted.sql
BLOCKER #2 CREATE TABLE dbo.DeliveryNotes ( N FILESTREAM/FileTable: a .bak with FILESTREAM data does not restore, the link cannot replicate it [tsql-diff, link]
BLOCKER #6 ALTER DATABASE Fleet ADD LOG FILE second log file: .bak files with multiple log files cannot be restored [tsql-diff]
BLOCKER #17 EXEC sp_addlinkedserver @server = linked server FUELXLS via Microsoft.ACE.OLEDB.12.0: only SQL Server/Azure SQL targets [tsql-diff]
ROUTE #3 CREATE TABLE dbo.TruckPositions ( memory-optimized table: Business Critical only, not General Purpose [tsql-diff]
ROUTE #4 CREATE VIEW dbo.vTripsAllYears AS three-part name FleetArchive.dbo.Trips: works on MI only if FleetArchive moves to the same instance [tsql-diff]
ROUTE #5 ALTER DATABASE Fleet SET RECOVERY SIMPLE/BULK_LOGGED recovery: LRS needs FULL; native restore turns it into FULL [lrs, tsql-diff]
ROUTE #9 USE Fleet; CREATE DATABASE ENCRYPT TDE: move the certificate to MI before a native restore; the link needs the key in Key Vault (BYOK) [overview, link]
FIX #8 USE master; CREATE CERTIFICATE Fle CREATE CERTIFICATE FROM FILE: not on MI, create FROM BINARY [tsql-diff]
FIX #10 CREATE LOGIN [CORP\fleet_app] FROM Windows login: FROM WINDOWS not supported, create a Microsoft Entra login and ALTER USER ... WITH LOGIN [tsql-diff]
FIX #11 CREATE LOGIN [CORP\Dispatchers] FR Windows login: FROM WINDOWS not supported, create a Microsoft Entra login and ALTER USER ... WITH LOGIN [tsql-diff]
FIX #14 CREATE PROCEDURE dbo.usp_Startup A global trace flag(s) [1117, 1118] not on the MI list [tsql-diff]
FIX #14 CREATE PROCEDURE dbo.usp_Startup A session trace flag [4199]: session flags not supported [tsql-diff]
FIX #15 EXEC sp_configure 'remote access', sp_configure 'remote access': option not supported [tsql-diff]
FIX #18 CREATE PROCEDURE dbo.usp_LoadGps A BULK INSERT from \\files\gps\daily.csv: no file shares, load from Blob with DATA_SOURCE [tsql-diff]
FIX #21 EXEC msdb.dbo.sp_add_alert @name = Agent alert: alerts not supported yet [tsql-diff]
FIX #22 EXEC msdb.dbo.sp_set_sqlagent_prop Agent mail profile 'FleetMail': Agent uses only AzureManagedInstance_dbmail_profile, Agent settings are read-only [tsql-diff]
NOTE #7 ALTER DATABASE Fleet SET COMPATIBI compatibility level 100: kept as is after restore, raise it yourself [tsql-diff]
3 BLOCKER, 4 ROUTE, 9 FIX, 1 NOTE
== fleet_backup_restore.sql
BLOCKER #1 CREATE CREDENTIAL [https://fleetmi SAS SECRET starts with '?': drop it [restore-qs]
BLOCKER #5 RESTORE DATABASE Fleet FROM URL = RESTORE ... WITH MOVE, NORECOVERY, REPLACE, STATS: WITH options fail on MI [tsql-diff]
BLOCKER #6 RESTORE DATABASE Fleet FROM URL = RESTORE ... WITH RECOVERY: WITH options fail on MI [tsql-diff]
BLOCKER #7 RESTORE LOG Fleet FROM DISK = 'D:\ RESTORE LOG on MI: not possible by hand, use LRS [lrs, tsql-diff]
BLOCKER #7 RESTORE LOG Fleet FROM DISK = 'D:\ FROM DISK: MI restores FROM URL only [tsql-diff]
ROUTE #1 CREATE CREDENTIAL [https://fleetmi SAS sp=rwdlac: fine for BACKUP TO URL, but LRS fails with anything beyond Read and List; make a second token [lrs]
ROUTE #2 BACKUP DATABASE Fleet TO URL = 'ht 'backup' in container/folder (backups/fleet/full): reserved for LRS, LRS fails [lrs]
ROUTE #2 BACKUP DATABASE Fleet TO URL = 'ht nested folder fleet/full: LRS wants one flat folder per database [lrs]
...
FIX #1 CREATE CREDENTIAL [https://fleetmi credential name ends in '/': MI wants no trailing slash [restore-qs]
FIX #2 BACKUP DATABASE Fleet TO URL = 'ht DATABASE backup without CHECKSUM: slower restore, corruption risk [lrs]
NOTE #2 BACKUP DATABASE Fleet TO URL = 'ht one URL: a single block blob tops out near 195 GB, stripe it (MAXTRANSFERSIZE=4194304, BLOCKSIZE=65536) [b2url]
NOTE #3 BACKUP DATABASE Fleet TO URL = 'ht one URL: a single block blob tops out near 195 GB, stripe it (MAXTRANSFERSIZE=4194304, BLOCKSIZE=65536) [b2url]
5 BLOCKER, 7 ROUTE, 2 FIX, 2 NOTE
Reading the result
Three findings decide the project before any route is chosen. The FILESTREAM column stops every route: native restore, LRS and the link all start from the same database. The scans move out of the database, or Fleet goes to a VM, which is what the migration overview suggests for a hard FILESTREAM dependency. The second log file has to be removed on the source before the backup is taken. The Excel linked server needs a different feed, such as OPENROWSET over a CSV in Blob storage.
The ROUTE lines narrow the choice. The memory-optimized table means Business Critical, and on that tier LRS cutover waits for replica seeding, which points at the link. The cross-database view means FleetArchive moves to the same instance, at the same time. TDE means a certificate migration or Key Vault work first.
What the scan did not flag matters too. The sp_send_dbmail procedure is clean: Database Mail works on Managed Instance, only file attachments do not. The SQL login fleet_report is supported as is, but its SID is the post-migration problem below. And the drafted backup script had four separate problems for one restore; every one of them fails at run time, on the instance, with the clock running.
The commands, generated and checked
For Fleet, with storage account fleetmig and one flat folder per database. The native route, four stripes:
-- [source] SQL Server 2016 or later: SAS token with read, write, list
CREATE CREDENTIAL [https://fleetmig.blob.core.windows.net/migration]
WITH IDENTITY = 'SHARED ACCESS SIGNATURE',
SECRET = '<sas token, no leading ?>';
GO
BACKUP DATABASE [Fleet]
TO URL = 'https://fleetmig.blob.core.windows.net/migration/Fleet/Fleet_full_1of4.bak',
URL = 'https://fleetmig.blob.core.windows.net/migration/Fleet/Fleet_full_2of4.bak',
URL = 'https://fleetmig.blob.core.windows.net/migration/Fleet/Fleet_full_3of4.bak',
URL = 'https://fleetmig.blob.core.windows.net/migration/Fleet/Fleet_full_4of4.bak'
WITH COMPRESSION, CHECKSUM, FORMAT,
MAXTRANSFERSIZE = 4194304, BLOCKSIZE = 65536, STATS = 10;
GO
-- [mi] same container; the instance only reads
CREATE CREDENTIAL [https://fleetmig.blob.core.windows.net/migration]
WITH IDENTITY = 'SHARED ACCESS SIGNATURE',
SECRET = '<sas token, no leading ?>';
GO
RESTORE FILELISTONLY FROM URL = '.../Fleet_full_1of4.bak', ... ; -- same four URLs
GO
RESTORE DATABASE [Fleet] FROM URL = '.../Fleet_full_1of4.bak', ... ; -- no WITH clause
GO
For LRS, the same full backup plus ALTER DATABASE [Fleet] SET RECOVERY FULL first, then differential and log backups WITH COMPRESSION, CHECKSUM, FORMAT into the same folder, and the Azure CLI in continuous mode, flags as on the LRS page:
az sql midb log-replay start -g rg-fleet --mi mi-fleet -n Fleet \
--storage-uri "https://fleetmig.blob.core.windows.net/migration/Fleet" \
--storage-sas "<sas with sp=rl only, no leading ?>"
az sql midb log-replay show -g rg-fleet --mi mi-fleet -n Fleet
# after the tail-log backup shows as restored
az sql midb log-replay complete -g rg-fleet --mi mi-fleet -n Fleet \
--last-backup-name "Fleet_log_042.trn"
Then I ran the generated T-SQL back through sqlglot and through the scanner:
$ python gen_commands.py check 2>/dev/null
-- sqlglot 30.17.0, read='tsql': native
12 tokens parse: Command CREATE CREDENTIAL [https://fleetmig.blob.core.window
38 tokens parse: no grammar BACKUP DATABASE [Fleet] TO URL = 'https://fleetmig.b
12 tokens parse: Command CREATE CREDENTIAL [https://fleetmig.blob.core.window
19 tokens parse: no grammar RESTORE FILELISTONLY FROM URL = 'https://fleetmig.bl
20 tokens parse: no grammar RESTORE DATABASE [Fleet] FROM URL = 'https://fleetmi
...
== generated native + LRS T-SQL
ROUTE #8 BACKUP DATABASE [Fleet] TO URL = ' differential backup: only LRS restores these on MI, not RESTORE by hand [lrs, tsql-diff]
ROUTE #9 BACKUP LOG [Fleet] TO URL = 'https log backup: only LRS restores these on MI, not RESTORE by hand [lrs, tsql-diff]
NOTE #8 BACKUP DATABASE [Fleet] TO URL = ' one URL: a single block blob tops out near 195 GB, stripe it (MAXTRANSFERSIZE=4194304, BLOCKSIZE=65536) [b2url]
0 BLOCKER, 2 ROUTE, 0 FIX, 1 NOTE
Be clear about what that proves. sqlglot 30.17 has no grammar for BACKUP or RESTORE: it rejects even BACKUP DATABASE Fleet TO DISK = 'a.bak', and treats CREATE CREDENTIAL as an opaque command. What it does give is its T-SQL tokenizer, which raised an error on a statement with an unclosed quote or bracket when I tested one. So the check is: every statement tokenizes, and the MI rules find no blocker. The two ROUTE lines are expected, since differential and log backups are what LRS is for. The single-URL differential is small enough here; stripe it if yours is not.
After cutover: what to check on the managed instance
Nothing below moves with the database; system databases cannot be restored, so master and msdb objects are scripted and recreated (MI migration guide).
- Compatibility level. A restored database keeps its level if it is 100 or higher; below 100 is not supported (MI T-SQL differences). Raise it with
ALTER DATABASE [Fleet] SET COMPATIBILITY_LEVEL = 160;when you are ready, following the Query Store workflow the compatibility level page links to. - Logins and SIDs. A SQL login recreated with a new SID leaves its database user orphaned. Find them, then recreate the login with the old SID or remap (orphaned users). Windows users map to Microsoft Entra logins with
ALTER USER [CORP\fleet_app] WITH LOGIN = [fleet_app@corp.example](Windows users to MI). - SQL Agent jobs. Script and recreate them. T-SQL and SSIS steps run, command shell steps do not, and email notifications need the profile
AzureManagedInstance_dbmail_profile(MI T-SQL differences). - Linked servers. Recreate them; only SQL Server and Azure SQL targets, with SQL or Entra authentication.
- Database Mail. Recreate account and profile; test
sp_send_dbmailwithout attachments. - Cross-database queries. They work within the instance (feature comparison), so run each view and procedure that uses a three-part name once every database it names has arrived.
- Service Broker and accelerated database recovery. If either was off on the source, it cannot be turned on afterwards; enable before migrating (migration overview).
-- in the restored database: users whose login SID is not on the instance
SELECT dp.type_desc, dp.sid, dp.name AS user_name
FROM sys.database_principals AS dp
LEFT JOIN sys.server_principals AS sp ON dp.sid = sp.sid
WHERE sp.sid IS NULL AND dp.authentication_type_desc = 'INSTANCE';
-- fix one: same SID as the source, or remap to an existing login
CREATE LOGIN fleet_report WITH PASSWORD = '<password>', SID = 0x...;
ALTER USER fleet_report WITH LOGIN = fleet_report;
Then compare row counts and checksums on both sides; the data validation guide has the queries I use.
What I did not run
No SQL Server, no managed instance, no Azure subscription were involved. I did not take a backup, restore one, start LRS, create a link or open DMS. Everything above the scan output is Microsoft's documentation, linked at each claim; the scanner, the sample scripts and the generated commands ran locally, offline, and the output is what they printed. The az commands follow the syntax on the LRS page and were not executed. The scanner is a first pass over a script; run Microsoft's assessment in Azure Arc on the real instance before you commit to a route.
Sources
- SQL Server to Azure SQL Managed Instance: Migration overview
- SQL Server to Azure SQL Managed Instance: Migration guide
- T-SQL differences between SQL Server and Azure SQL Managed Instance
- Quickstart: Restore a backup to Azure SQL Managed Instance
- SQL Server backup to URL for Azure Blob Storage
- Overview of Log Replay Service
- Migrate databases from SQL Server by using Log Replay Service
- Managed Instance link overview
- What is Azure Database Migration Service?
- SQL Server migration in Azure Arc to Azure SQL Managed Instance
- DBCC TRACEON trace flags
- Features comparison: Azure SQL Database and Azure SQL Managed Instance
- ALTER DATABASE compatibility level
- Troubleshoot orphaned users
- Migrate SQL Server Windows users and groups to SQL Managed Instance using T-SQL