Skip to content

Commit 73096d2

Browse files
authored
Merge pull request #99412 from stevestein/sqldb-ie-12.18
SQL DB - new import export from Azure VM article
2 parents cd32679 + d1e9119 commit 73096d2

File tree

5 files changed

+167
-0
lines changed

5 files changed

+167
-0
lines changed
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
---
2+
title: Import or export a SQL database
3+
description: Import or export an Azure SQL database without allowing Azure services to access the server.
4+
services: sql-database
5+
ms.service: sql-database
6+
ms.subservice: migration
7+
ms.custom:
8+
ms.devlang:
9+
ms.topic: conceptual
10+
author: stevestein
11+
ms.author: sstein
12+
ms.reviewer:
13+
ms.date: 01/08/2020
14+
---
15+
# Import or export an Azure SQL database without allowing Azure services to access the server
16+
17+
This article shows you how to import or export an Azure SQL database when *Allow Azure Services* is set to *OFF* on the Azure SQL server. The workflow uses an Azure virtual machine to run SqlPackage to perform the import or export operation.
18+
19+
## Sign in to the Azure portal
20+
21+
Sign in to the [Azure portal](https://portal.azure.com/).
22+
23+
## Create the Azure virtual machine
24+
25+
Create an Azure virtual machine by selecting the **Deploy to Azure** button.
26+
27+
This template allows you to deploy a simple Windows virtual machine using a few different options for the Windows version, using the latest patched version. This will deploy a A2 size VM in the resource group location and return the fully qualified domain name of the VM.
28+
<br><br>
29+
30+
<a href="https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2F101-vm-simple-windows%2Fazuredeploy.json" target="_blank">
31+
<img src="https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/1-CONTRIBUTION-GUIDE/images/deploytoazure.png"/>
32+
</a>
33+
34+
For more information, see [Very simple deployment of a Windows VM](https://github.com/Azure/azure-quickstart-templates/tree/master/101-vm-simple-windows).
35+
36+
37+
## Connect to the virtual machine
38+
39+
The following steps show you how to connect to your virtual machine using a remote desktop connection.
40+
41+
1. After deployment completes, go to the virtual machine resource.
42+
43+
![VM](./media/import-export-from-vm/vm.png)
44+
45+
2. Select **Connect**.
46+
47+
A Remote Desktop Protocol file (.rdp file) form appears with the public IP address and port number for the virtual machine.
48+
49+
![RDP form](./media/import-export-from-vm/rdp.png)
50+
51+
3. Select **Download RDP File**.
52+
53+
> [!NOTE]
54+
> You can also use SSH to connect to your VM.
55+
56+
4. Close the **Connect to virtual machine** form.
57+
5. To connect to your VM, open the downloaded RDP file.
58+
6. When prompted, select **Connect**. On a Mac, you need an RDP client such as this [Remote Desktop Client](https://itunes.apple.com/us/app/microsoft-remote-desktop/id715768417?mt=12) from the Mac App Store.
59+
60+
7. Enter the username and password you specified when creating the virtual machine, then choose **OK**.
61+
62+
8. You might receive a certificate warning during the sign-in process. Choose **Yes** or **Continue** to proceed with the connection.
63+
64+
65+
66+
## Install SqlPackage
67+
68+
[Download and install the latest version of SqlPackage](https://docs.microsoft.com/sql/tools/sqlpackage-download).
69+
70+
71+
72+
73+
For additional information, see [SqlPackage.exe](https://docs.microsoft.com/sql/tools/sqlpackage).
74+
75+
## Create a firewall rule to allow the VM access to the database
76+
77+
Add the virtual machine's public IP address to the SQL Database server firewall.
78+
79+
The following steps create a server-level IP firewall rule for your virtual machine's public IP address and enables connectivity from the virtual machine.
80+
81+
1. Select **SQL databases** from the left-hand menu and then select your database on the **SQL databases** page. The overview page for your database opens, showing you the fully qualified server name (such as **servername.database.windows.net**) and provides options for further configuration.
82+
83+
2. Copy this fully qualified server name to use when connecting to your server and its databases.
84+
85+
![server name](./media/sql-database-get-started-portal/server-name.png)
86+
87+
3. Select **Set server firewall** on the toolbar. The **Firewall settings** page for the database server opens.
88+
89+
![server-level IP firewall rule](./media/sql-database-get-started-portal/server-firewall-rule.png)
90+
91+
4. Choose **Add client IP** on the toolbar to add your virtual machine's public IP address to a new server-level IP firewall rule. A server-level IP firewall rule can open port 1433 for a single IP address or a range of IP addresses.
92+
93+
5. Select **Save**. A server-level IP firewall rule is created for your virtual machine's public IP address opening port 1433 on the SQL Database server.
94+
95+
6. Close the **Firewall settings** page.
96+
97+
98+
99+
## Export a database using SqlPackage
100+
101+
To export a SQL database using the [SqlPackage](https://docs.microsoft.com/sql/tools/sqlpackage) command-line utility, see [Export parameters and properties](https://docs.microsoft.com/sql/tools/sqlpackage#export-parameters-and-properties). The SqlPackage utility ships with the latest versions of [SQL Server Management Studio](https://docs.microsoft.com/sql/ssms/download-sql-server-management-studio-ssms) and [SQL Server Data Tools](https://docs.microsoft.com/sql/ssdt/download-sql-server-data-tools-ssdt), or you can download the latest version of [SqlPackage](https://docs.microsoft.com/sql/tools/sqlpackage-download).
102+
103+
We recommend the use of the SqlPackage utility for scale and performance in most production environments. For a SQL Server Customer Advisory Team blog about migrating using BACPAC files, see [Migrating from SQL Server to Azure SQL Database using BACPAC Files](https://blogs.msdn.microsoft.com/sqlcat/20../../migrating-from-sql-server-to-azure-sql-database-using-bacpac-files/).
104+
105+
This example shows how to export a database using SqlPackage.exe with Active Directory Universal Authentication. Replace with values that are specific to your environment.
106+
107+
```cmd
108+
SqlPackage.exe /a:Export /tf:testExport.bacpac /scs:"Data Source=<servername>.database.windows.net;Initial Catalog=MyDB;" /ua:True /tid:"apptest.onmicrosoft.com"
109+
```
110+
111+
112+
113+
114+
## Import a database using SqlPackage
115+
116+
To import a SQL Server database using the [SqlPackage](https://docs.microsoft.com/sql/tools/sqlpackage) command-line utility, see [import parameters and properties](https://docs.microsoft.com/sql/tools/sqlpackage#import-parameters-and-properties). SqlPackage has the latest [SQL Server Management Studio](https://docs.microsoft.com/sql/ssms/download-sql-server-management-studio-ssms) and [SQL Server Data Tools](https://docs.microsoft.com/sql/ssdt/download-sql-server-data-tools-ssdt). You can also download the latest version of [SqlPackage](https://docs.microsoft.com/sql/tools/sqlpackage-download).
117+
118+
For scale and performance, we recommend using SqlPackage in most production environments rather than using the Azure portal. For a SQL Server Customer Advisory Team blog about migrating using `BACPAC` files, see [migrating from SQL Server to Azure SQL Database using BACPAC Files](https://blogs.msdn.microsoft.com/sqlcat/2016/10/20/migrating-from-sql-server-to-azure-sql-database-using-bacpac-files/).
119+
120+
The following SqlPackage command imports the **AdventureWorks2017** database from local storage to an Azure SQL Database server. It creates a new database called **myMigratedDatabase** with a **Premium** service tier and a **P6** Service Objective. Change these values as appropriate for your environment.
121+
122+
```cmd
123+
sqlpackage.exe /a:import /tcs:"Data Source=<serverName>.database.windows.net;Initial Catalog=myMigratedDatabase>;User Id=<userId>;Password=<password>" /sf:AdventureWorks2017.bacpac /p:DatabaseEdition=Premium /p:DatabaseServiceObjective=P6
124+
```
125+
126+
> [!IMPORTANT]
127+
> To connect to a SQL Database server managing a single database from behind a corporate firewall, the firewall must have port 1433 open. To connect to a managed instance, you must have a [point-to-site connection](sql-database-managed-instance-configure-p2s.md) or an express route connection.
128+
129+
This example shows how to import a database using SqlPackage with Active Directory Universal Authentication.
130+
131+
```cmd
132+
sqlpackage.exe /a:Import /sf:testExport.bacpac /tdn:NewDacFX /tsn:apptestserver.database.windows.net /ua:True /tid:"apptest.onmicrosoft.com"
133+
```
134+
135+
## Performance considerations
136+
137+
Export speeds vary due to many factors (for example, data shape) so it's impossible to predict what speed should be expected. SqlPackage may take considerable time, particularly for large databases.
138+
139+
To get the best performance you can try the following strategies:
140+
141+
1. Make sure no other workload is running on the database. Create a copy before export may be the best solution to ensure no other workloads are running.
142+
2. Increase database service level objective (SLO) to better handle the export workload (primarily read I/O). If the database is currently GP_Gen5_4, perhaps a Business Critical tier would help with read workload.
143+
3. Make sure there are clustered indexes particularly for large tables.
144+
4. Virtual machines (VMs) should be in the same region as the database to help avoid network constraints.
145+
5. VMs should have SSD with adequate size for generating temp artifacts before uploading to blob storage.
146+
6. VMs should have adequate core and memory configuration for the specific database.
147+
148+
## Store the imported or exported .BACPAC file
149+
150+
The .BACPAC file can be stored in [Azure Blobs](https://docs.microsoft.com/azure/storage/blobs/storage-blobs-overview), or [Azure Files](https://docs.microsoft.com/azure/storage/files/storage-files-introduction).
151+
152+
To achieve the best performance, use Azure Files. SqlPackage operates with the filesystem so it can access Azure Files directly.
153+
154+
To reduce cost, use Azure Blobs, which cost less than a premium Azure file share. However, it will require you to copy the [.BACPAC file](https://docs.microsoft.com/sql/relational-databases/data-tier-applications/data-tier-applications#bacpac) between the the blob and the local file system before the import or export operation. As a result the process will take longer.
155+
156+
To upload or download .BACPAC files, see [Transfer data with AzCopy and Blob storage](../storage/common/storage-use-azcopy-blobs.md), and [Transfer data with AzCopy and file storage](../storage/common/storage-use-azcopy-files.md).
157+
158+
Depending on your environment, you might need to [Configure Azure Storage firewalls and virtual networks](../storage/common/storage-network-security.md).
159+
160+
## Next steps
161+
162+
- To learn how to connect to and query an imported SQL Database, see [Quickstart: Azure SQL Database: Use SQL Server Management Studio to connect and query data](sql-database-connect-query-ssms.md).
163+
- For a SQL Server Customer Advisory Team blog about migrating using BACPAC files, see [Migrating from SQL Server to Azure SQL Database using BACPAC Files](https://techcommunity.microsoft.com/t5/DataCAT/Migrating-from-SQL-Server-to-Azure-SQL-Database-using-Bacpac/ba-p/305407).
164+
- For a discussion of the entire SQL Server database migration process, including performance recommendations, see [SQL Server database migration to Azure SQL Database](sql-database-single-database-migrate.md).
165+
- To learn how to manage and share storage keys and shared access signatures securely, see [Azure Storage Security Guide](https://docs.microsoft.com/azure/storage/common/storage-security-guide).
68.7 KB
Loading
19.2 KB
Loading
73.2 KB
Loading

articles/sql-database/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,8 @@
359359
href: sql-database-design-first-database-csharp.md
360360
- name: Load and move data
361361
items:
362+
- name: Import or export from an Azure VM
363+
href: import-export-from-vm.md
362364
- name: Import a database from a BACPAC file
363365
href: sql-database-import.md
364366
- name: Export a database to a BACPAC file

0 commit comments

Comments
 (0)