Search code examples
sqlsql-serverazureazure-sql-databaseazure-data-sync

Migrate on-prem SQL Server database to Azure SQL database


We're in the process of a server migration from an on-prem server (Win2008R2) to Azure PaaS.

To move the DBs, we used the Microsoft Data Migration Assistant (DMA) tool, which worked great and we can connect to the migrated Azure DB via SQL Server Management Studio.

Considering:

  • Made quite a few changes to the migrated Azure DB (tables, stored procedures, indexes) to work with the apps in Azure
  • Combined multiple on-prem DBs into one DB in Azure via DMA to save costs
  • On-prem DB is continually being modified by insert/update operations (multiple tables) during the migration process

Question: what is the best and fastest way to migrate data (all vs missing/updated) considering the above?


Solution

  • I would recommend you to migrate first only the schema of your on-premises databases to Azure SQL Databases and then let Azure SQL Data Sync to migrate the data to Azure and keep it updated on Azure SQL Database.

    My suggestion to start with an empty schema on the Azure SQL Database side is because when SQL data Sync finds data on-premises and on Azure it start comparing both databases and that consumes a lot of resources.

    On the initial sync SQL Data Sync may consume a lot of resources on the on-premises database server even when having an empty schema on the Azure side, for that you can use SQL Server Resource Governor to cap the CPU used by the data sync sessions in your on premises SQL Server, and this way avoid big performance impact possibly affecting database users.

    When you are ready, you can switch your users (gradually or not if SQL Data Sync is on bi-directional mode) to Azure. Once your users have been migrated, you can then remove the member database (the on-premises database) from the SQL Data Sync configuration and stop SQL Data Sync operation.