Skip to content

Insight and analysis of technology and business strategy

How to migrate from on-premises to Azure SQL database

The Azure SQL Database is improving its capabilities day-by-day. The “Cloud-first” strategy used by Microsoft is also an incentive to start using the Azure’s SQL Database as a Service (DaaS) offer. In this article I’ll explain all the steps to move your database from on-premises to Azure, using three different approaches. You will need to choose the right one based on your migration strategy and on the database that you are migrating. Don't forget that not all the features supported on-premises are supported on Azure, so some additional work may be needed prior to the migration. I’ll show how to migrate a database to Azure SQL Database by using two general methods:
  • Using the SQL Server Management Studio - Recommended when there are no code compatibility issues blocking the cloud migration.
  • Using the SQL Server Data Tools - This approach is highly recommended when there are migration barriers, as the process of detecting and fixing the issues is simpler and more direct.
If you are in doubt about which one to use, the recommendation is to start by using the SQL Server Management Studio approach and, in case of failures, proceed with the SQL Server Data Tools.

Migrate Using SQL Server Management Studio
SQL Server Management Studio (SSMS) offers two direct ways to transfer a database to an Azure SQL Database. To proceed, connect to the SQL Server instance and run either the “SQL Database Deployment Wizard” or the “Export data-tier application” option from SQL Server Management Studio. img1 If you cannot find the preferred option, you will need to update your SQL Server Management Studio (SSMS), which is now a free standalone product. You can do this by downloading the latest version. The primary difference between the two options is that the “Deploy“ option requires an existing Database server in Azure and will directly deploy the on-premises database to that location. The difference is that afterwards the “Export” option will create a file to be imported from the Azure portal. The exported file can be loaded straight to an Azure Blob Storage account, which will help avoid an extra step to copy the file (recommended). NOTE: For both options, an Azure Blob Storage account with a container and an Azure SQL server are needed.

Migration Steps Using the Deployment Wizard
  1. Right-click the database and select the Deploy Database to Microsoft Azure SQL Databaseimg2
  2. Fill in the required fields. The server information is for the target (Azure SQL Database server). The settings to define the price tier are also configured at this stage. The bacpac file will be created locally and then applied on the Azure SQL Server, and because of this, we will need to store the bacpac file in a temporary place in the server.
  3. Click Next.
img3
  1. Review the settings and click Finish.img4
  2. Wait for the process to complete. At this stage the wizard will validate the database, create the DACPAC file, and apply the Azure SQL Server to create the database.
img5
  1. The database is now ready to use the server admin account to access the Azure SQL Server.
 
Migration Steps using the Export Data-Tier Application Process
  1. Right-click the database and select the Export Data-tier Application.011316_1528_HOWDOYOUMIG6.png
  2. Save the file in an Azure Blob Storage Account. You will need the account name and access key.
  3. Select the container and click Next.011316_1528_HOWDOYOUMIG7.png
  4. Click Finish, and wait for the processing to complete.
  5. Once the process completes a "Success" message is seen as shown in the screen below. Otherwise, there are items needing to be resolved to make the database capable of being converted into an Azure SQL Database.011316_1528_HOWDOYOUMIG8.png
  6. Connect to the Azure portal and choose the SQL Servers.
  7. Select the SQL Server location where the database should be created, and then click the Import Database icon as shown below.011316_1528_HOWDOYOUMIG9.png
  8. Complete the required settings, including the BACPAC file location, price tier, and server administrator’s password, and then click Create.011316_1528_HOWDOYOUMIG10.png
  9. Once the process completes, the database will be seen in the list.
011316_1528_HOWDOYOUMIG11.png

Migrate Using SQL Server Data Tools
By using the SSMS to migrate the database using a DACPAC, we don’t have the needed flexibility to properly detect and fix the found issues. For this purpose, the SQL Server Data Tools - Business Intelligence is a better option to analyze the database objects. To proceed with this option, follow the steps below.  

Creating the Main Project

  1. Using the SQL Server Data Tools BI, click the SQL Server Object Explorer tab and connect to the on-premises instance:
011316_1528_HOWDOYOUMIG12.png
  1. Right-click the database to be migrated to Azure, and then click Create New Project.
  2. Add a name to the project and select a path to save the project files.
  3. Click next and wait for the processing to complete.
011316_1528_HOWDOYOUMIG13.png
  1. After the project is created, right-click the project root, go to properties and change the Target Platform to Azure SQL Database. Save and close.
011316_1528_HOWDOYOUMIG14.png
  1. Right-click the project and click Rebuild. If problems are detected, all the errors will be shown in the Error List.
011316_1528_HOWDOYOUMIG15.png
  1. Go to File->New->Project, give a project name (I will name it AWAzure) and in the Solution option, click Add to solution:
011316_1528_HOWDOYOUMIG16.png    
Creating the New Schema
In order to filter the non-supported features and find the code to be corrected, the next step is a Schema Comparison creation. Follow the steps shown: 011316_1528_HOWDOYOUMIG17.png
  1. Now, select the options. Click the icon shown.
011316_1528_HOWDOYOUMIG18.png
  1. In the Schema Compare Options window, click to clear the following known non-supported items:
  • Aggregates
  • Application Roles
  • Assemblies
  • Asymmetric Keys
  • Broker Providers
  • Certificates
  • Contracts
  • Defaults
  • Extended Properties
  • Filegroups
  • FIleTables
  • Full-Text Stoplists
  • Full-Text Catalogs
  • Full-Text Indexes
  • Message Types
  • Partition Functions
  • Partition Schemes
  • Queues
  • Remote Service Bindings
  • Rules
  • Sequences
  • Services
  • Symmetric Keys
  • Used-Defined Types (CLR)
  • XML Indexes
  • XML Schemas Collections
  1. Click Ok and save the Schema Comparison, as it can be useful later.
  2. Select the source: The On-premises database.
011316_1528_HOWDOYOUMIG19.png
  1. Select the Target: The empty SQL Server create project.
011316_1528_HOWDOYOUMIG20.png We will have the following: 011316_1528_HOWDOYOUMIG21.png
  1. Now, click Compare. Wait for the process to complete and then click Update (click YES in the confirmation pop-up), to update the selected target.
  1. Next, go to the AWAzure (the target) project, right-click on the root, go to properties, and change the Target Platform to Azure SQL Database.
  1. Click Save and Close the screen.
 
Resolving Problems
Now it’s time to resolve the problems. Check the errors tab and double click on each found item to open the code. Resolve the issue and save the file. 011316_1528_HOWDOYOUMIG22.png Use the filter to ensure you are dealing with the right project. 011316_1528_HOWDOYOUMIG23.png    
Deploying the Schema
After the schema revision, we can publish the database.
  1. To publish the database, right click the AWAzure project, and click Publish.
  1. Edit the target instance and connect to the Azure SQL Server:
011316_1528_HOWDOYOUMIG24.png
  1. Fill in the database name and click Publish.
img6

Moving the Data
The schema is deployed. Now it is time to move the data. To do this, use the Import and Export Wizard, from the SQL Server Management Studio.
  1. Connect to the on-premises instance, right click the database used as the data source and follow the steps shown:
img7
  1. In the wizard, confirm the Server name and the source database, and then click Next.
img8 Now, do the same for the Azure SQL Database.
  1. In the Destination field, select SQL Server Native Client 11.0, fill in the server name, and select the target database.img9
  2. Click Next.
  3. For this step, keep the first option selected, and then click Next.img10
Select all the tables and views from the source. Notice that SQL Server will automatically map the target tables on Azure. About data hierarchy: If foreign key constraints are being used in the database, the data migration should be made in phases to avoid failure. This needs to be analyzed prior to the final migration. img11
  1. Make sure that all the tables are highlighted and click Edit Mappings.
  2. Select Enable Identity Insert and then click Ok.
  3. Then, in the main Wizard window click Next.
img12
  1. Make sure the Run immediately check box is selected and click Next.
img13
  1. In the following screen, review the options, and then click Finish.
img14
  1. Monitor and the data transfer and close the wizard.
img15   That’s it. I hope that the steps were clear and this article was useful. If you have questions, do not hesitate in post your comment or contact me using twitter ( @murilocmiranda). “See” you in another article.   Discover more about our expertise in SQL Server.

Top Categories

  • There are no suggestions because the search field is empty.

Tell us how we can help!

dba-cloud-services
Upcoming-Events-banner