Home / Databases / SQL Server

DatabasesHow-toIntermediate

Migrate SQL Server to Azure SQL Managed Instance with Log Replay Service (LRS)

Move databases to Azure SQL MI from native backups in Blob Storage using the Log Replay Service. Covers backup requirements, uploading with azcopy, continuous vs autocomplete mode, monitoring, the final cutover and common errors.

Deepak Bhardwaj2 min read

Applies toSQL Server 2008+ (any edition) to Azure SQL Managed Instance; Azure CLI or PowerShell

When to choose LRS

  • No direct network between SQL Server and MI (backups travel via Blob Storage).
  • Versions or editions not supported by the MI link.
  • You want to use your existing backup jobs (full + diff + log).

Downtime = time to take and restore the last log backup + app switch (usually minutes).

1. Backup requirements

  • Backups with CHECKSUM (required).
  • One folder per database in the container (/sales/, /hr/); full, diff and log files for that database only.
  • Stripe large databases across multiple files for speed.
BACKUP DATABASE Sales TO URL = 'https://stmig.blob.core.windows.net/backups/sales/sales_full.bak'
  WITH CHECKSUM, COMPRESSION, FORMAT;
BACKUP LOG Sales TO URL = 'https://stmig.blob.core.windows.net/backups/sales/sales_log_0001.trn'
  WITH CHECKSUM, COMPRESSION;

Or back up to disk and upload with azcopy:

azcopy copy "D:\Backups\Sales\*" "https://stmig.blob.core.windows.net/backups/sales/?<sas>" --recursive

2. Start LRS

Continuous mode (you decide when to complete; best for production cutovers):

az sql midb log-replay start -g rg-sql --mi sqlmi-prod -n Sales \
  --storage-uri "https://stmig.blob.core.windows.net/backups/sales" \
  --storage-sas "<read+list SAS without leading ?>"

Managed identity of the MI can be used instead of a SAS (current versions; grant Storage Blob Data Reader).

Autocomplete mode (all backups already uploaded; finishes automatically):

az sql midb log-replay start ... -a --last-bn "sales_log_0042.trn"

3. Monitor

az sql midb log-replay show -g rg-sql --mi sqlmi-prod -n Sales

Keep shipping new log backups to the folder; LRS restores them in order.

4. Cutover

  1. Stop the app.
  2. Take a final tail-log backup with NORECOVERY on the source (prevents further changes) and upload it.
  3. Complete:
az sql midb log-replay complete -g rg-sql --mi sqlmi-prod -n Sales --last-backup-name "sales_log_tail.trn"
  1. The database comes online read-write on MI. Switch connection strings; run smoke tests.

5. Common errors

Error Fix
Backups without checksum Retake backups WITH CHECKSUM
Files for multiple databases in one folder One folder per database
SAS missing list permission or expired New SAS with rl and enough lifetime (days)
LRS stopped after 30 days Continuous mode has a time limit — plan the cutover inside it, or restart
Log chain broken Another backup job took a log backup elsewhere — pause other log backups during migration

Warning

While LRS runs, make sure no other log backup job (your backup tool, maintenance plan) takes log backups that don't land in the LRS folder. A missing log file breaks the chain and forces a restart from a new full backup.