Once you find and fix compatibility issues, the next step is to select a migration tool or method and perform the actual migration. There are different methods available for various scenarios. The selection largely depends on downtime, database size, and network speed/quality.
Here's a comparison of various migration methods to help you correctly choose a migration method:
Migration Method |
Description |
Downtime |
Database Size |
---|---|---|---|
SQL Server Management Studio – Deploy Database to Azure SQL Database |
Wizard-based GUI to export on-premises database to
|
Yes (depends on database size) |
Small to Medium databases |
Sqlpackage.exe |
Command-line utility to export on-premises databases to
|
Yes (Depends on database size) |
Small to Medium databases |
Manual (Dacpac and BCP) |
Use
|
Yes (Depends on database size) |
Large to Very Large databases (improved performance from parallel bcp in) |
SQL Azure Migration Wizard |
Free Codeplex wizard-based GUI utility. It scripts out schema in a T-SQL file and then uses bcp, as mentioned in the previous method. |
Yes (Depends on database size) |
Large to Very Large |
Data Migration Assistant |
Wizard-based GUI standalone migration software. Uses T-SQL script to migrate schema and bcp to migrate data. Allows you to choose which objects and table to migrate. Detects and lists out compatibility issues as well. |
Yes (Depends on database size) |
Large to Very Large databases |
Transactional Replication |
Azure SQL Database as a subscriber to on-premises SQL Server Database publisher. Higher complexity, cost, and resources. Supports SQL Server 2012+ as the publisher and Azure SQL Database as the subscriber. |
Short |
Large to Very Large databases |
Let us consider our example of ToyStore Ltd. from the previous chapter. Mike has performed all the necessary steps that he had to complete before he could migrate the SQL Server database to Azure. Now, all he has to do is perform the migration using the tool of his choice. He selects SQL Server Management Studio. In this section, we’ll see how to use SQL Server Management Studio for migrating a database to Azure.
bacpac
file. You can change it if you wish to or you can leave it as default. Click Next to continue:SSMS checks for compatibility issues, and the migration process terminates because of compatibility issues. Click on Error besides the exporting database option to view the error's details:
bacpac
package. Click OK to close the Error Details window. The next step is to fix the errors.C:codeChapter02FixCompatibilityIssues.sql
in SQL Server Management studio. The script fixes the compatibility issues by commenting/correcting out the unsupported code within the stored procedures:USE [toystore] GO ALTER proc [dbo].[BackUpDatabase] As -- Backup command isn't supported on Azure SQL Database --backup database toystore to disk = 'C: orystore.bak' --with init, stats=10 GO ALTER proc [dbo].[EmailProc] As -- Database mail isn't supported on Azure SQL Database --EXEC msdb.dbo.sp_send_dbmail -- @profile_name = 'toystore Administrator', -- @recipients = '[email protected]', -- @body = 'The stored procedure finished successfully.', -- @subject = 'Automated Success Message' ; select * from city
SELECT TOP (1000) [OrderID] ,[CustomerID] ,[SalespersonPersonID] ,[PickedByPersonID] ,[ContactPersonID] ,[BackorderOrderID] ,[OrderDate] ,[ExpectedDeliveryDate] ,[CustomerPurchaseOrderNumber] ,[IsUndersupplyBackordered] ,[Comments] ,[DeliveryInstructions] ,[InternalComments] ,[PickingCompletedWhen] ,[LastEditedBy] ,[LastEditedWhen] FROM [toystore].[Sales].[Orders]
Congratulations! You have successfully migrated your SQL Server database to an Azure SQL Database.
This section describes how to migrate a SQL Server database, such as the
toystore
database, to an Azure SQL Database using the Data Migration Assistant.
toystore
.toystore
and click Add to continue.As per the DMA, you have one instance of Cross-database reference and Service Broker which aren't supported in Azure SQL Database.
DMA lists out the stored procedure which failed the compatibility test.
To fix the errors, open
C:codeChapter02FixCompatibilityIssues.sql
in SQL Server Management Studio and execute it against the
toystore
database.
DMA will re-assess and notify you that there are no compatibility issues:
toystoremigration
.toystore
from the list of available databases and click Next:This migrates data from the selected tables in parallel and therefore can be used for large to very large databases:
In this section, we will make use of the toy manufacturing company introduced in an earlier chapter as an example to understand how to migrate an SQL Server database to an Azure SQL Database using Transactional Replication.
toystore
as the database to be published. Click Next to continue:Click Next to continue:
Under the Connect to the publisher section, select By impersonating the process account. The process account must have read and write access on the publisher database:
Check the Use the security settings from the Snapshot Agent, under the Log Reader Agent text box. The Log Reader Agent will run under the same account as the Snapshot agent. You can choose different security settings for the Log Reader agent if you wish to:
Click Finish to continue.
Click Finish to create the publication:
Click + to complete the New Publication Wizard.
In the Object Explorer, expand the Replication node, and then expand Local Publications; observe that the publication toystorepub is added to the publication list:
toystorepub
publication is listed out under the toystore
database. If it's the only publication, it'll be selected by default. Click Next to continue:Click Next to continue:
In the Connect to Server dialog box, provide the Azure SQL Server name and SQL Authentication login credentials to connect to the Azure SQL Server. Click Connect to continue:
The
Subscribers page will now list the Azure SQL Server under the Subscriber column and
toystore
database under the
Subscription Database column. Select the Azure SQL Server if it's not already selected and click
Next to continue.
The distribution agent can run under the context of the domain account or SQL Server Agent Service account (not recommended) for the agent. Provide a domain account that has appropriate access to the Distribution Server, which in our case is the same as the Publication Server.
Under the Connect to the Distributor section, select the default option (by impersonating the process account). You can also use a SQL Server login if you wish to.
Under the Connect to the Subscriber section, provide the Azure SQL Server, SQL Server login, and password.
Click OK to go back to the Distribution Agent Security page. It'll now show the selected security options:
Click Next to continue.
The wizard will create the subscription and will initiate the snapshot agent to apply the initial snapshot on the subscriber.
Once the initial snapshot is applied, all of the transactions on the publisher will be sent to the subscriber.
Click close to end the wizard.
In the replication monitor, expand the
My Publishers node, then
expand the SQL Server Instance name node. The
toystorepub
publication will be listed there. Select the
toystorepub
publication to check the synchronization health:
It may take time to generate and apply the initial snapshot depending on the database's size.
To further verify that the objects are migrated to Azure SQL Database, switch to SSMS and open Object Explorer if it's not already open.
Connect to your Azure SQL Database and expand the
Tables
node. Observe that all of the tables are listed under the
Tables
node:
3.15.29.119