Migrate SQL Server from Azure to ApsaraDB RDS

Updated at:

This article explains how to use the one-stop cloud migration feature in the RDS console or the migration feature in the DTS console to migrate data from SQL Server on the Azure platform—including Azure SQL Database, Azure SQL Managed Instance, and SQL Server on Azure Virtual Machines—to Alibaba Cloud ApsaraDB RDS for SQL Server.

Prerequisites

Note

For SQL Server on Azure Virtual Machines, Enterprise Edition must be 2008 or later, and Standard Edition must be 2016 SP1 or later. SQL Server 2017 is not supported.

Precautions

Review these key precautions before migration. Ignoring them may cause the task to fail or report errors:

  • Database count limit: A single task can migrate a maximum of 10 databases. Exceeding this limit can affect stability and performance.

  • Table count limit: For tasks that include incremental migration, you can synchronize a maximum of 1,000 tables from the source database. Exceeding this limit may cause task delays or instability.

  • Source database operation restrictions: During the schema migration and full migration phases, do not perform any DDL operations, such as modifying the schema of a database or table. Otherwise, the task will fail.

  • CDC-related limitations: If CDC is enabled for a table in the source database and the data in a single column exceeds 64 KB, you must run the EXEC sp_configure 'max text repl size', -1; command in advance to adjust the configuration. Otherwise, the task may fail.

  • Table structure requirements: Each table you migrate must have a primary key or a unique constraint to ensure data uniqueness. Otherwise, duplicate data may occur in the target database.

  • Foreign keys and triggers: For tasks that include incremental data migration, you must disable all enabled triggers and foreign keys in the target database. Otherwise, the task may fail or data may be lost.

  • Database naming conventions: If a source database name is incompatible with RDS for SQL Server naming conventions, you must first manually create the database in the target RDS for SQL Server instance. Otherwise, the task may fail.

  • Transaction log retention period: For an incremental migration task, the transaction log of the source database must be retained for at least 24 hours. For a task that includes both full migration and incremental migration, the required retention period is at least 7 days. Otherwise, the task may fail or data inconsistencies may occur.

All limitations and notes

Note

DTS does not migrate foreign keys from the source database to the destination database. As a result, DTS does not migrate cascading operations from the source database.

Billing

Migration type

Instance configuration fee

Internet traffic fee

Schema migration and full data migration

Free of charge.

When the Access Method parameter of the destination database is set to Public IP Address, you are charged for Internet traffic. For more information, see Billing overview.

Incremental data migration

Charged. For more information, see Billing overview.

Database account permissions

For a successful data migration, the source and destination database accounts must have the following permissions:

Azure SQL Database

  • Structural migration: Requires the SELECT permission.

  • Full migration: Requires the SELECT permission.

  • Incremental migration: Requires the sysadmin role for CDC.

Note

The highest-privilege account (server administrator) in the Azure SQL Database console already has the required permissions.

  • For databases that use the vCore-based purchasing model, all tiers support CDC. For databases that use the DTU-based purchasing model, only instances at the S3 tier or higher support CDC.

  • For more information, see the Azure documentation or contact technical support.

RDS SQL Server

Structural migration, full migration, and incremental migration require read and write permissions.

Procedure

The one-stop migration feature in the RDS console is straightforward, migrating the schema, full data, and incremental data by default; the migration feature in the DTS console supports custom migration types and more advanced settings, but requires a more complex configuration.

Method 1: Use One-stop Cloud

  1. Go to the ApsaraDB RDS instance list, select a region at the top of the page, and then click the ID of the target instance.

  2. In the left-side navigation pane, click Data Migration and Synchronization to go to the Data Migration page.

  3. Click One-stop Cloud and configure the source and destination databases.

    Category

    Parameter

    Description

    N/A

    Task Name

    Specify a descriptive name for the task to easily identify it. The name does not need to be unique. You can also keep the automatically generated task name.

    Source Database

    Database Type

    The default value is SQL Server. No selection is required.

    Type

    Select Azure.

    Access Method

    Select Public IP Address or Express Connect, VPN Gateway, or Smart Access Gateway depending on how your SQL Server database on Azure connects to Alibaba Cloud.

    Important

    If the source database is an Azure SQL Managed Instance, select Public IP Address.

    Instance Region

    • If Access Method is set to Public IP Address: Select the region where the SQL Server database on Azure is located.

      Note

      If the region of your SQL Server database is not in the list, select the region that is geographically closest to your database.

    • If Access Method is set to Express Connect, VPN Gateway, or Smart Access Gateway: Select the region of the Alibaba Cloud Virtual Private Cloud (VPC) to which the SQL Server database is connected.

    Connected VPC

    Select the ID of the Alibaba Cloud Virtual Private Cloud (VPC) to which the SQL Server database on Azure is connected.

    Note

    This parameter is available only when you set Access Method to Express Connect, VPN Gateway, or Smart Access Gateway.

    Domain Name or IP

    Enter the domain name or IP address of the SQL Server database on Azure.

    Note

    A domain name is recommended.

    Port Number

    Enter the service port number.

    Database Account

    Enter the database account for the SQL Server database on Azure and ensure that the account has the required permissions.

    Important

    The format for an Azure SQL Database account is <administrator account>@<instance server name>. For example, if the administrator account for the Azure SQL Database is testuser and the instance server name is dtstest (you can run the SELECT @@SERVERNAME AS ServerName command to query the name), then you must enter testuser@dtstest for the Database Account.

    Database Password

    Enter the password for the database account.

    Encryption

    • If SSL encryption is not enabled on the source database, select Non-encrypted.

    • If SSL encryption is enabled on the source database, select SSL-encrypted. By default, Data Transmission Service (DTS) trusts the server certificate.

    Destination Database

    Database Type

    The default value is SQL Server. No selection is required.

    Access Method

    The default value is Alibaba Cloud Instance. No selection is required.

    Instance Region

    The region of the ApsaraDB RDS for SQL Server instance. This parameter cannot be changed.

    Instance ID

    The ID of the ApsaraDB RDS for SQL Server instance. This parameter cannot be changed.

    Database Account

    Enter the database account for the ApsaraDB RDS for SQL Server instance and ensure that the account has the required permissions.

    Database Password

    Enter the password for the database account.

    Encryption

    • If SSL encryption is not enabled on the destination database, select Non-encrypted.

    • If SSL encryption is enabled on the destination database, select SSL-encrypted. By default, DTS trusts the server certificate.

  4. After you complete the configuration, click Test Connection and Go to Next Step at the bottom of the page.

    Important

    Ensure you add the DTS server CIDR blocks from the pop-up window to the whitelist of your SQL Server database on Azure. Be aware that Adding DTS IP addresses can introduce security risks. To mitigate them, take appropriate security measures, such as using strong passwords and restricting port access.

  5. The system evaluates your source database type and generates the following two migration plans.

    • If you select the Full and Incremental Data Migration plan, click Configure Objects at the bottom of the page and proceed to the next step.

    • If you select another migration plan, you do not need to perform the subsequent steps.

      Note

      Click View Migration Documentation at the bottom of the page to view the steps for the selected plan.

  6. On the Configure Objects page, specify the objects to migrate.

    Parameter

    Description

    Method to Migrate Triggers in Source Database

    During incremental data migration, migrating triggers to the destination database prematurely can cause data inconsistency between the source and destination databases. You can select a trigger migration method based on your business requirements. We recommend that you select Manual Migration. For more information, see Configure trigger synchronization or migration.

    Note

    If the objects to be migrated do not involve triggers, you can keep the default setting.

    Source Objects

    In the Source Objects box, click the objects to migrate, and then click Right arrow to move them to the Selected Objects box.

    Note

    You can select objects for migration at the database, table, or column level. If you select a table or column, other objects such as views, triggers, and stored procedures are not migrated to the destination database.

    Selected Objects

    • To change the name of a migration object in the destination instance, right-click the migration object in the Selected Objects section to modify it. For more information, see Object Name Mapping.

    • To remove a selected object, click the object in the Selected Objects pane, and then click image to move it to the Source Objects pane.

    Note
    • If you use object name mapping, the migration of other objects that depend on the renamed object might fail.

    • To filter data by using a WHERE clause, right-click a table in the Selected Objects pane, and then set filter conditions in the dialog box that appears.

    • To select SQL operations for migration at the database or table level, right-click an object in the Selected Objects pane, and then select the desired SQL operations in the dialog box that appears.

  7. Optional: Expand Advanced settings to configure advanced parameters.

    Parameter

    Description

    Enable Throttling for Full Data Migration

    During full migration, DTS consumes read and write resources on the source and destination databases, which may increase the database load. If required, you can enable throttling for the full migration task. You can set Queries per second (QPS) to the source database, RPS of Full Data Migration, and Data migration speed for full migration (MB/s) to reduce the load on the destination database.

    Enable Throttling for Incremental Data Migration

    If required, you can also choose to set speed limits for the incremental migration task. You can set RPS of Incremental Data Migration and Data migration speed for incremental migration (MB/s) to reduce the load on the destination database.

    Data Verification Mode

    Full data verification consumes database read resources. If you select Full Data Verification, you must also set the Maximum number of rows of data read per second by full verification (RPS) and Maximum amount of data read per second by full verification (MBps) to limit the verification speed and reduce the database load.

    Note

    A parameter value of 0 indicates no limit. If both Maximum number of rows of data read per second by full verification (RPS) and Maximum amount of data read per second by full verification (MBps) are 0, the speed is unlimited.

  8. Save the task and run a precheck.

    • To view the parameters for configuring this instance when you call the API operation, move the pointer over the Next: Save Task Settings and Precheck button and click Preview OpenAPI parameters in the bubble that appears.

    • If you do not need to view or have finished viewing the API parameters, click Next: Save Task Settings and Precheck at the bottom of the page.

    Note
    • Before the migration task starts, DTS performs a precheck. The task starts only after it passes the precheck.

    • If the precheck fails, click View Details next to the failed check item, fix the issue based on the prompt, and then run the precheck again.

    • If a warning is reported during the precheck:

      • For check items that cannot be ignored, click View Details next to the failed item, fix the issue based on the prompt, and then run the precheck again.

      • For check items that can be ignored, you can click Confirm Alert Details, Ignore, OK, and Precheck Again to skip the alert item and run the precheck again. If you choose to ignore a warning, it may cause issues such as data inconsistency and pose risks to your business.

  9. When the Success Rate is 100%, click Next: Purchase Instance.

  10. Purchase the instance.

    1. On the Purchase page, select the link specification for the data migration instance. For more information, see the following table.

      Category

      Parameter

      Description

      New Instance Class

      Resource Group Settings

      Select the resource group to which the instance belongs. The default value is default resource group. For more information, see What is Resource Management?

      Instance Class

      DTS provides migration specifications with different performance levels. The link specification affects the migration speed. You can select a specification based on your business scenario. For more information, see Data migration link specifications.

    2. After the configuration is complete, read and select Data Transmission Service (Pay-as-you-go) Service Terms.

    3. Click Buy and Start. In the OK dialog box that appears, click OK.

      You can view the progress of the migration task on the Data Migration Tasks list page.

      Note
      • If the migration task does not include incremental migration, it stops automatically after the full migration is complete. After the task stops, its Status changes to Completed.

      • If the migration task includes incremental migration, it does not stop automatically. The incremental migration task continues to run. While the incremental migration task is running, the Status of the task is Running.

Method 2: Migrate data with the DTS console

  1. Go to the Data Transmission Service (DTS) console.

  2. In the left-side navigation pane, click Data Migration. In the top navigation bar, select a region.

  3. Click Create Task and configure the source and destination database information.

    Category

    Parameter

    Description

    N/A

    Task Name

    Specify a descriptive name for the task for easier identification. The name does not need to be unique. You can also use the default name generated by the system.

    Source Database

    Select Existing Connection

    If you have saved the source database information on the DTS Data Connection Management page, you can select the saved connection to avoid manual entry.

    Database Type

    Select SQL Server.

    Access Method

    Select Public IP Address or Express Connect, VPN Gateway, or Smart Access Gateway depending on how your SQL Server database on Azure connects to Alibaba Cloud.

    Important

    If the source database is an Azure SQL Managed Instance, select Public IP Address.

    Instance Region

    • If you set Access Method to Public IP Address, select the region where the SQL Server database on Azure is located.

      Note

      If the region of the source database is not listed, select the geographically closest region.

    • If you set Access Method to Express Connect, VPN Gateway, or Smart Access Gateway, select the region of the VPC that is used to connect to the SQL Server database.

    Replicate Data Across Alibaba Cloud Accounts

    In this example, a database instance under the current Alibaba Cloud account is used. Select No.

    Note

    This parameter is available only when you set Access Method to Express Connect, VPN Gateway, or Smart Access Gateway.

    Connected VPC

    Select the ID of the VPC that is used to connect to the SQL Server database.

    Note

    This parameter is available only when you set Access Method to Express Connect, VPN Gateway, or Smart Access Gateway.

    Domain Name or IP

    Enter the hostname or IP address of the SQL Server database on Azure.

    Note

    We recommend that you enter the hostname.

    Port Number

    Enter the service port of the SQL Server database on Azure.

    Database Account

    Enter the database account of the SQL Server database on Azure, and ensure that the account has the required permissions.

    Important

    The format for an Azure SQL Database account is <administrator account>@<instance server name>. For example, if the administrator account for the Azure SQL Database is testuser and the instance server name is dtstest (you can run the SELECT @@SERVERNAME AS ServerName command to query the name), then you must enter testuser@dtstest for the Database Account.

    Database Password

    Enter the password for the database account.

    Encryption

    • If SSL encryption is disabled for the source database, select Non-encrypted.

    • If SSL encryption is enabled for the source database, select SSL-encrypted. DTS trusts the server-side certificate by default.

    Destination Database

    Select Existing Connection

    If you have saved the destination database information on the DTS Data Connection Management page, you can select the saved connection to avoid manual entry.

    Database Type

    Select SQL Server.

    Access Method

    Select Alibaba Cloud Instance.

    Instance Region

    Select the region where the destination RDS for SQL Server instance is located.

    Instance ID

    Select the ID of the destination RDS for SQL Server instance.

    Database Account

    Enter the database account of the destination RDS for SQL Server instance, and ensure that the account has the required permissions.

    Database Password

    Enter the password for the database account.

    Encryption

    • If SSL encryption is disabled for the destination database, select Non-encrypted.

    • If SSL encryption is enabled for the destination database, select SSL-encrypted. DTS trusts the server-side certificate by default.

  4. After completing the configuration, click Test Connectivity and Proceed at the bottom of the page.

    Important

    Add the DTS server IP addresses displayed in the pop-up dialog box to the allowlist of your SQL Server database on Azure. Adding IP addresses to an allowlist can pose security risks. Take appropriate security measures, such as using strong passwords and restricting port access.

  5. Configure the task objects.

    1. On the Configure Objects page, configure the objects that you want to migrate.

      Parameter

      Description

      Migration Types

      • For a full data migration, select Schema Migration and Full Data Migration.

      • For a zero-downtime migration, select Schema Migration, Full Data Migration, and Incremental Data Migration.

      Note

      Method to Migrate Triggers in Source Database

      During incremental data migration, migrating triggers to the destination database prematurely can cause data inconsistency between the source and destination databases. You can select a trigger migration method based on your business requirements. We recommend that you select Manual Migration. For more information, see Configure trigger synchronization or migration.

      Note
      • This parameter is available only if you select both Schema Migration and Incremental Data Migration for Migration Types.

      • If the migration objects do not include triggers, you can keep the default setting.

      SQL Server Incremental Synchronization Mode

      Select Polling and querying CDC instances for incremental synchronization.

      Note

      This parameter is available only if Migration Types includes Incremental Data Migration.

      The maximum number of tables for which CDC is enabled that DTS supports.

      In this example, you can keep the default value.

      Processing Mode of Conflicting Tables

      • Precheck and Report Errors: Checks whether tables with the same names exist in the destination database. If no tables with the same names exist, the precheck is passed. If tables with the same names exist, an error is reported during the precheck, and the data migration task does not start.

        Note

        If a table in the destination database has the same name but cannot be easily deleted or renamed, you can change the name of the table in the destination database. For more information, see Object name mapping.

      • Ignore Errors and Proceed: Skips the check for tables with the same names.

        Warning

        Selecting Ignore Errors and Proceed may cause data inconsistency and business risks. For example:

        • If the table schemas are consistent and a record in the destination database has the same primary key value as a record in the source database:

          • During full migration, DTS keeps the record in the destination database. The record from the source database is not migrated.

          • During incremental migration, DTS does not keep the record in the destination database. The record from the source database overwrites the record in the destination database.

        • If the table schemas are inconsistent, only some columns of data may be migrated, or the migration may fail. Proceed with caution.

      Capitalization of Object Names in Destination Instance

      You can configure the case sensitivity policy for the names of migrated objects, such as databases, tables, and columns, in the destination instance. By default, DTS default policy is selected. You can also choose to keep the case sensitivity consistent with the default policy of the source or destination database. For more information, see Case sensitivity of object names in the destination database.

      Source Objects

      In the Source Objects box, click the objects to migrate, and then click Right arrow to move them to the Selected Objects box.

      Note

      You can select objects for migration at the database, table, or column level. If you select a table or column, other objects such as views, triggers, and stored procedures are not migrated to the destination database.

      Selected Objects

      • To change the name of a migration object in the destination instance, right-click the migration object in the Selected Objects section to modify it. For more information, see Object Name Mapping.

      • To remove a selected object, click the object in the Selected Objects pane, and then click image to move it to the Source Objects pane.

      Note
      • If you use object name mapping, the migration of other objects that depend on the renamed object might fail.

      • To filter data by using a WHERE clause, right-click a table in the Selected Objects pane, and then set filter conditions in the dialog box that appears.

      • To select SQL operations for migration at the database or table level, right-click an object in the Selected Objects pane, and then select the desired SQL operations in the dialog box that appears.

    2. Click Next: Advanced Settings to configure advanced parameters.

      Parameter

      Description

      Dedicated Cluster for Task Scheduling

      By default, DTS schedules tasks on a shared cluster. You do not need to select one. If you want more stable tasks, you can purchase a dedicated cluster to run DTS migration tasks.

      Retry Time for Failed Connections

      After the migration task starts, if the connection to the source or destination database fails, DTS reports an error and immediately begins to retry the connection. The default retry duration is 720 minutes. You can customize the retry time to a value from 10 to 1440 minutes. We recommend that you set the duration to more than 30 minutes. If DTS reconnects to the source and destination databases within the specified duration, the migration task automatically resumes. Otherwise, the task fails.

      Note
      • For multiple DTS instances that share the same source or destination, the network retry time is determined by the setting of the last created task.

      • Because you are charged for the task during the connection retry period, we recommend that you customize the retry time based on your business needs, or release the DTS instance as soon as possible after the source and destination database instances are released.

      Retry Time for Other Issues

      After the migration task starts, if a non-connectivity issue, such as a DDL or DML execution exception, occurs in the source or destination database, DTS reports an error and immediately begins to retry the operation. The default retry duration is 10 minutes. You can customize the retry time to a value from 1 to 1440 minutes. We recommend that you set the duration to more than 10 minutes. If the related operations succeed within the specified retry duration, the migration task automatically resumes. Otherwise, the task fails.

      Important

      The value of Retry Time for Other Issues must be less than the value of Retry Time for Failed Connections.

      Enable Throttling for Full Data Migration

      During full migration, DTS consumes read and write resources on the source and destination databases, which may increase the database load. If required, you can enable throttling for the full migration task. You can set Queries per second (QPS) to the source database, RPS of Full Data Migration, and Data migration speed for full migration (MB/s) to reduce the load on the destination database.

      Note
      • This configuration item is available only if you select Full Data Migration for Migration Types.

      • You can also adjust the full migration speed after the migration instance is running.

      Enable Throttling for Incremental Data Migration

      If required, you can also choose to set speed limits for the incremental migration task. You can set RPS of Incremental Data Migration and Data migration speed for incremental migration (MB/s) to reduce the load on the destination database.

      Note
      • This configuration item is available only if you select Incremental Data Migration for Migration Types.

      • You can also adjust the incremental migration speed after the migration instance is running.

      Environment Tag

      Based on your business requirements, you can select an environment tag to identify the instance. In this example, you do not need to select a tag.

      Configure ETL

      Choose whether to enable the extract, transform, and load (ETL) feature. For more information, see What is ETL? Valid values:

      Monitoring and Alerting

      Select whether to set alerts and receive alert notifications based on your business needs.

      • No: Does not set an alert.

      • Yes: Configure alerts by setting an alert threshold and an alert contact. If a migration fails or the latency exceeds the threshold, the system sends an alert notification.

    3. Click Next: Data Verification to configure a data verification task.

      To use the data verification feature, see Configure data verification.

  6. Save the task and run a precheck.

    • To view the parameters for configuring this instance when you call the API operation, move the pointer over the Next: Save Task Settings and Precheck button and click Preview OpenAPI parameters in the bubble that appears.

    • If you do not need to view or have finished viewing the API parameters, click Next: Save Task Settings and Precheck at the bottom of the page.

    Note
    • Before the migration task starts, DTS performs a precheck. The task starts only after it passes the precheck.

    • If the precheck fails, click View Details next to the failed check item, fix the issue based on the prompt, and then run the precheck again.

    • If a warning is reported during the precheck:

      • For check items that cannot be ignored, click View Details next to the failed item, fix the issue based on the prompt, and then run the precheck again.

      • For check items that can be ignored, you can click Confirm Alert Details, Ignore, OK, and Precheck Again to skip the alert item and run the precheck again. If you choose to ignore a warning, it may cause issues such as data inconsistency and pose risks to your business.

  7. Purchase the instance.

    1. When the Success Rate is 100%, click Next: Purchase Instance.

    2. On the Purchase page, select the link specification for the data migration instance. For more information, see the following table.

      Category

      Parameter

      Description

      New Instance Class

      Resource Group Settings

      Select the resource group to which the instance belongs. The default value is default resource group. For more information, see What is Resource Management?

      Instance Class

      DTS provides migration specifications with different performance levels. The link specification affects the migration speed. You can select a specification based on your business scenario. For more information, see Data migration link specifications.

    3. After the configuration is complete, read and select Data Transmission Service (Pay-as-you-go) Service Terms.

    4. Click Buy and Start. In the OK dialog box that appears, click OK.

      You can view the progress of the migration task on the Data Migration Tasks list page.

      Note
      • If the migration task does not include incremental migration, it stops automatically after the full migration is complete. After the task stops, its Status changes to Completed.

      • If the migration task includes incremental migration, it does not stop automatically. The incremental migration task continues to run. While the incremental migration task is running, the Status of the task is Running.

Appendix 1: Supported SQL operations

DML operations

INSERT, UPDATE, and DELETE

Note

Incremental data migration does not support UPDATE statements that modify only a large field.

DDL operations

  • CREATE TABLE

    Note

    CREATE TABLE is not supported for tables with partitions or when the table definition contains a function.

  • ALTER TABLE

    Only the ADD COLUMN and DROP COLUMN clauses are supported.

  • DROP TABLE

  • CREATE INDEX and DROP INDEX

Note
  • Transactional DDL is not supported. For example, a single SQL statement that adds multiple columns or mixes DDL and DML operations can cause data loss.

  • DDL operations that use a user-defined type are not supported.

  • Online DDL is not supported.

  • DDL operations that use a reserved keyword as an attribute name are not supported.

  • DDL operations executed by a system stored procedure are not supported.

  • TRUNCATE TABLE is not supported.

Appendix 2: Supported objects for schema migration

  • DTS supports schema migration for the following objects: tables, views, triggers, synonyms, SQL stored procedures, SQL functions, plan guides, user-defined types, rules, defaults, and sequences.

  • DTS does not support schema migration for the following objects: assemblies, service brokers, full-text indexes, full-text catalogs, distributed schemas, distributed functions, Common Language Runtime (CLR) stored procedures, CLR scalar-valued functions, CLR table-valued functions, internal tables, systems, or aggregate functions.

FAQ

  • Does ApsaraDB RDS one-stop cloud migration support selecting the objects to verify?

    No. By default, the objects to verify are the same as the objects for migration.

  • What is the full verification mode for ApsaraDB RDS one-stop cloud migration?

    It is a hash verification with a 100% sampling ratio.

  • What is the baseline for full verification in ApsaraDB RDS one-stop cloud migration?

    It uses the union of the source and destination databases as the baseline to verify data consistency.