CHAPTER 3
As you adopt and embrace the cloud platform, some of the on premise workload needs to be migrated to Azure for the benefit of cost and efficiency. Usually the Dev/Cert/QA/test environments are the good candidates for initial migration since these servers have minimum business impact and need not be running 24X7. Migrating these environments also gives maximum cost benefits by running the VMs only during business hours and turning it OFF when not in use.
In this chapter, we will discuss the various methods for migrating on premise SQL Server databases to SQL Server on Azure VMs.
The primary migration methods are:
The method used for migration is primarily dependent on the target version of SQL Server instance in Azure VM and size of the database backup. The following table lists each of the primary migration methods and discusses when the use of each method is most appropriate.
Table 2: Choosing the right method for migration
Method | Source database version | Destination database version | Source database backup size constraint | Notes |
|---|---|---|---|---|
Use the Deploy a SQL Server Database to a Microsoft Azure VM wizard | SQL Server 2005 or greater | SQL Server 2014 or greater | > 1 TB | Fastest and simplest method, use whenever possible to migrate to a new or existing SQL Server instance in an Azure virtual machine |
Perform on-premises backup using compression and manually copy the backup file into the Azure virtual machine | SQL Server 2005 or greater | SQL Server 2005 or greater | Use only when you cannot use the wizard, such as when the destination database version is less than SQL Server 2012 SP1 CU2 or the database backup size is larger than 1 TB (12.8 TB with SQL Server 2016) | |
Perform a backup to URL and restore into the Azure virtual machine from the URL | SQL Server 2012 SP1 CU2 or greater | SQL Server 2012 SP1 CU2 or greater | > 1 TB (For SQL Server 2016, < 12.8 TB) | Generally using backup to URL is equivalent in performance to using the wizard and not quite as easy |
Detach and then copy the data and log files to Azure blob storage and then attach to SQL Server in Azure virtual machine from URL | SQL Server 2005 or greater | SQL Server 2014 or greater | Use when attaching database files to SQL Server in an Azure VM storing these files using the Azure Blob storage service, particularly with very large databases | |
Convert on-premises machine to Hyper-V VHDs, upload to Azure Blob storage, and then deploy a new virtual machine using uploaded VHD | SQL Server 2005 or greater | SQL Server 2005 or greater | Use when bringing your own SQL Server license, when migrating a database that you will run on an older version of SQL Server, or when migrating system and user databases together as part of the migration of database dependent on other user databases and/or system databases. | |
Ship hard drive using Windows Import/Export Service | SQL Server 2005 or greater | SQL Server 2005 or greater | Use the Windows Import/Export Service when manual copy method is too slow, such as with very large databases |
The above table and the methods for migration are taken from Carl Rebeler’s following article
This wizard available in SQL Server Management Studio (SSMS) is the recommended method for migrating an on-premises user database running on SQL Server 2005 or greater to SQL Server 2014 or greater when the compressed database backup file is less than 1 TB.
Before using the wizard, ensure to download and install the latest version of SSMS on the client workstation. The latest version of this wizard incorporates the most recent updates to the Azure portal and supports the newest Azure VM images in the gallery (older versions of the wizard may not work).
This method requires us to configure an open endpoint for the SQL Server Cloud Adapter service on the Microsoft Azure gateway with private port of 11435. This port is created as part of SQL Server 2014 or SQL Server 2016 provisioning on a Microsoft Azure VM. The Cloud Adapter also creates a Windows Firewall rule to allow its incoming TCP connections at default port 11435. This endpoint enables the wizard to utilize the Cloud Adaptor service to copy the backup files from the on-premises instance to the Azure VM. For more information, see Cloud Adapter for SQL Server.
You can use the following Azure PowerShell Cmdlet to add a SQL Server Cloud Adapter Endpoint on port 11435.
Code Listing 15: Adding an SQL Server Cloud Adapter Endpoint to Azure VM
Add-AzureEndpoint -Name "SQL Server Cloud Adapter" -Protocol tcp -LocalPort 11435 -PublicPort 11435 -VM $vm | Update-AzureVM | Out-Null |
This method involves the following steps

Figure 6: Deploy Database to Microsoft Azure VM Wizard
If you specified an existing Cloud Service and VM, you will prompted for admin username and password to connect to the VM.
If you specified a new virtual machine, you will prompted to select the following options
In addition, you need to click check box to accept the creation of new self-generated certificate for this new Microsoft Azure Virtual Machine.
The wizard takes a compressed backup of the database to the specified backup location and Cloud Adaptor service within the VM is used to restore the backup into the target SQL instance in Azure VM.
The time taken by the wizard is dependent on the backup size and time to copy the compressed backup across network and restore time which in turn is dependent on the Azure VM Compute Size.
If you created a new virtual machine, configure the Azure virtual machine and the SQL Server instance by following the steps mentioned in the previous chapter.
Use this method when you cannot use the Deploy a SQL Server Database to a Microsoft Azure VM wizard either because you are migrating to a version of SQL Server prior to SQL Server 2014 or your backup file is larger than 1 TB. If your backup file is larger than 1 TB, you must stripe it because the maximum size of a VM disk is 1 TB. Use the following general steps to migrate a user database using this manual method:
This method is no different from the previous method except for the fact that data is backed up directly to Azure blob storage and is restored from the same location. The following article provides the steps to create a backup to Azure Blob Storage URL:
https://msdn.microsoft.com/library/dn435916.aspx
Microsoft introduced backup to URL option starting with SQL 2012 SP1 CU2; hence, this method can only be used when the source SQL Server instance is already on or above SQL 2012 SP1 CU2.
Use the backup to URL method when you cannot use the Deploy a SQL Server Database to a Microsoft Azure VM wizard because your backup file is larger than 1 TB and you are migrating from and to SQL Server 2016. For databases smaller than 1 TB or running a version of SQL Server prior to SQL Server 2016, use of the wizard is recommended. With SQL Server 2016, striped backup sets are supported, are recommended for performance, and required to exceed the size limits per blob. For very large databases, the use of the Windows Import/Export Service is recommended.
Use this method when you plan to store these files using the Azure Blob storage service and attach them to SQL Server running in an Azure VM, particularly with very large databases. Use the following general steps to migrate a user database using this manual method:
This method is same as we discussed previously in the topic Creating a Syspreped image of SQL Server in Hyper-V & adding it to Azure. This method is useful when you want to bring your own license and migrate the entire SQL instance along with the user and system databases to Azure VM.
Microsoft Azure team introduced Windows Import/Export Service method couple of years back as an efficient solution for transferring large volume of on premise data into Azure blob storage This method is used when volume of data to be transferred is too high and transferring it over the network may be prohibitive or may not be a feasible solution. With Windows Import/Export service you can ship TBs of encrypted data via hard drives through FedEx to Azure data centers. The primary requirements for this method is only 3.5 inch SATA II/III hard drive are supported with maximum size up to 6 TB. Further the hard drives needs to be bit locker encrypted before sending it to Azure Data centers. The detailed steps to transfer the data using Windows Import/Export Service is mentioned in the following article
https://azure.microsoft.com/en-us/documentation/articles/storage-import-export-service/
This method is useful when you want to minimize the failover time for migration. In this method, we add the SQL Server instance on Azure VM as an Azure replica of the on premise SQL Server instance using the new Add an Azure replica wizard. This method requires a hybrid-IT environment where on premise subnet has a site-to-site VPN with Windows Azure. After the always-on availability group is set up and synchronized, you can failover at any time and go live with the database on Azure. The on premise database can then be removed from availability group and decommissioned once the migration is successful.