We use machine learning technology to do auto-translation. Click "English" on top navigation bar to check Chinese version.
Migrate SQL Server databases in Azure to Amazon RDS Custom for SQL Server using backup and bacpac files and Amazon S3
In this post we show you how to migrate from Azure to
Amazon RDS Custom for SQL Server is a managed database service for legacy, custom, and packaged applications that require access to the underlying OS and database environment. Amazon RDS Custom for SQL Server automates the setup, operation, and backup of databases in the Amazon Web Services Cloud while granting you access to the database and underlying OS. With Amazon RDS Custom, you get the automation of
As of this writing, the Azure platform has three offerings: Azure SQL VM, Azure SQL Managed Instance, and Azure SQL Database. A common method to migrate SQL Server databases from Azure to Amazon RDS Custom for SQL Server is by using the native backup and restore method (.bak files). However, this is only supported by Azure SQL VM and Azure SQL Managed Instance, which also supports data-tier application backup package files (.bacpac). Azure SQL Database only supports .bacpac files. For .bacpac files migration limitation details, and for a similar solution to Amazon RDS for SQL Server, refer to
Solution overview
The following diagram illustrates the typical steps for a SQL Server database migration from Microsoft Azure to Amazon RDS Custom for SQL Server.
The steps are as follows:
- Back up the database:
- Azure SQL VM and Azure SQL Managed Instance support native SQL Server backup and restore and .bacpac files.
- Azure SQL Database only supports .bacpac files.
- Copy the native backup file or .bacpac file to
Amazon Simple Storage Service (Amazon S3). - Download the file from Amazon S3 to the RDS instance and restore it.
Prerequisites
We assume that you have the following prerequisites:
- Basic knowledge of Amazon Web Services services such as Amazon EC2, the
Amazon Web Services Command Line Interface (Amazon Web Services CLI), and Amazon RDS. - Basic knowledge of how to set up and launch RDS Custom for SQL Server instances and Azure Platform. For more information, refer to
Creating and connecting to a DB instance for Amazon RDS for Custom SQL Server . - Background knowledge about
data-tier applications andSqlPackage . - An S3 bucket configured to store the necessary database backup files. For instructions, refer to
Creating a bucket .
This solution incurs cost on your account due to the Amazon Web Services resource setup and utilization. Refer to
Migrate SQL databases on Azure Platform using .bak files
This procedure involves performing a full backup of the SQL database hosted in Azure (supported in Azure SQL VM and Azure SQL Managed Instance offerings only), followed by differential and log backups, and then restoring the same backups to the target Amazon RDS Custom for SQL Server instance. Following this process can reduce application cutover time during the migration process. For more information, refer to
Migrate Azure SQL Database using .bacpac files
Bacpac is supported in all the three offerings (Azure SQL VM, Azure SQL Managed Instance, Azure SQL databases) in Azure platform. Bacpac is a compressed zip file (with extension .bacpac) that contains the metadata and data of the database. To ensure that the .bacpac file is transactional consistent, make sure that no write activity takes place during the export. A common method is to stop any write activity to the database or perform the export against a snapshot of the database. After a successful export of the .bacpac file, you can delete the snapshot.
The following are the steps involved in migrating a .bacpac file:
- Export the .bacpac file from your SQL database in Azure. You can use Azure Portal, SqlPackage.exe, Azure Data Studio, or PowerShell. For more information, refer to
Export to a BACPAC file – Azure SQL Database and Azure SQL Managed Instance . - Upload the .bacpac file to Amazon S3 by using either the Amazon Web Services CLI or Amazon S3 console. For details, refer to
Uploading objects . - Download the .bacpac file to the EC2 instance hosting Amazon RDS Custom for SQL Server using the Amazon Web Services CLI. It is recommended to use the D drive. For details on how to download the file, refer to
Downloading an object . - Import the .bacpac file to Amazon RDS Custom for SQL Server using the data-tier application, SqlPackage.exe.
For the rest of this post we assume steps 1-3 were completed and the .bacpac files were downloaded to the EC2 instance in D:\Backup
, and you could
Import the data-tier application using SSMS
Open SQL Server Management Studio (SSMS) on the EC2 instance that is hosting Amazon RDS Custom for SQL Server. SSMS has the wizard to import the data from .bacpac using the data-tier application.
- In SSMS, choose (right-click) Databases .
- Choose Import Data-tier Application .
- Select Import from local disk and enter the source location of the .bacpac file.
- Choose Next .
- For New database name , enter a name for the database.
All the SQL Server database files are stored in the D:\rdsdbdata\Data
directory. If you create or alter the database file location to be anywhere other than the D: drive, then Amazon RDS Custom places the DB instance outside the support perimeter. For more information, refer to
- Choose Next .
The status bar shows the import progress.
- When database creation is complete, choose Close .
SQLPackage.exe
Another method to import .bacpac files to Amazon RDS Custom for SQL Server is to use SQLPackage.exe, which is a command line utility. You must install this utility on Amazon RDS Custom for SQL Server. For more information, refer to
Complete the following steps:
-
Install SQLPackage.exe on the EC2 instance hosting Amazon RDS Custom for SQL Server. - Run the SQLPackage.exe from a CMD shell on the EC2 server hosting Amazon RDS Custom for SQL Server:
For example:
To learn more about SqlPackage import parameters, refer to
You can set the parameter TargetEncryptConnection
to either connect without encryption or to trust the server certificate. In the preceding example, the TargetEncryptConnection
is set to false
because it’s being run locally on Amazon RDS Custom for SQL Server. To learn more, refer to
You can also use PowerShell and Azure Data Studio to import the .bacpac file. For more information, refer to
Cleanup
Once you have finished your migration you can remove the files you no longer need from your EC2 instance and your S3 Bucket.
Summary
In this post, we covered how you can migrate SQL Server databases from Azure to Amazon RDS Custom for SQL Server using the bacpac method. You learned how to use native backup/restore for databases in Azure SQL VM and Azure SQL Managed Instance support and use .bacpac files for Azure SQL Databases.
If you have any questions or suggestions, leave them in the comments section.
About the Authors
InduTeja Aligeti is a Lead Database Consultant at Amazon Web Services. She has 16+years of experience working with Microsoft Technologies with a specialization in SQL Server. She focuses on helping customers to build high-available, cost-effective database solutions and migrate their large scale SQL Server databases to Amazon Web Services.
Priya Nair is a Database consultant at Amazon Web Services. She has 18 plus years of experience working with different database technologies. She works as database migration specialist to help Amazon customers to move their on-premises database environment to Amazon Web Services cloud database solutions.
Jose Amado-Blanco is a Sr. Consultant on Database Migration with over 25 years of experience working with Amazon Web Services Professional Services. He helps customers on their journey to migrate and modernize their database solutions from on-premises to Amazon Web Services.
The mentioned AWS GenAI Services service names relating to generative AI are only available or previewed in the Global Regions. Amazon Web Services China promotes AWS GenAI Services relating to generative AI solely for China-to-global business purposes and/or advanced technology introduction.