When a VM is the right target
- The app needs OS access, a specific version, unsupported PaaS features, or third-party agents.
- A quick exit from a data centre, with modernisation later.
- Moving to a VM is also the best time to upgrade SQL Server (for example 2014 → 2022).
1. Build the VM properly
- Use an Azure Marketplace SQL Server image (license included or pay with AHB) or install your own media.
- Memory-optimised sizes (E-series, M-series for very large) and Premium SSD v2 or Premium SSD with caching: ReadOnly for data, None for log.
- Separate disks for data, log and tempdb (tempdb on the local temp disk is supported and fast on many sizes).
- Register with the SQL IaaS Agent extension for automated patching, automated backup, licence management and portal insights:
az sql vm create -g rg-sql -n vm-sql01 --license-type AHUB --sql-mgmt-type Full -l centralindia
2. Move the data
| Method | Downtime | Notes |
|---|---|---|
| Backup to URL + restore | Final log backup + restore | Simple; full + log chain via Blob Storage |
| Log shipping to the Azure VM | Minutes | Good for many databases |
| Add the Azure VM as an AG replica (hybrid AG over VPN/ExpressRoute) | Seconds (planned failover) | Best for Tier 1; needs AG and a stretched cluster or distributed AG |
| Azure Migrate server migration | Replication of the whole VM | Moves the server as-is (same version) |
Backup to URL (managed identity or SAS credential)
CREATE CREDENTIAL [https://stmig.blob.core.windows.net/backups]
WITH IDENTITY = 'SHARED ACCESS SIGNATURE', SECRET = '<sas-token-without-?>';
BACKUP DATABASE Sales TO URL = 'https://stmig.blob.core.windows.net/backups/Sales_full.bak'
WITH COMPRESSION, CHECKSUM, STATS = 10;
On the Azure VM, create the same credential and RESTORE DATABASE ... FROM URL ... WITH NORECOVERY, then restore logs and finally WITH RECOVERY.
3. Instance objects
Copy-DbaLogin -Source sqlonprem01 -Destination vm-sql01
Copy-DbaAgentJob -Source sqlonprem01 -Destination vm-sql01
Copy-DbaLinkedServer -Source sqlonprem01 -Destination vm-sql01
Copy-DbaDbMail -Source sqlonprem01 -Destination vm-sql01
4. HA and DR in Azure
- Availability zones: two VMs in different zones with an AG; use multi-subnet AG design (no load balancer needed) — see the AG on Azure VMs post.
- DR: an async replica in a paired region, or Azure Site Recovery for less critical servers.
- Backups: automated backup via the extension, or Azure Backup for SQL Server in Azure VMs (log backups every 15 min, central policy).
5. Cutover
Follow the cutover runbook: stop app → final log backup/restore (or AG failover) → switch the DNS alias → smoke tests.
Tip
Put the app connection on a DNS alias (CNAME) before the migration. Cutover is then a DNS change, and rollback is changing it back.