Monday, November 25, 2019

Data Platform Tips 9 - Import a BACPAC file to a Azure SQL Database

Let us take the BACPAC file created as part of the previous tip and import it into a new database.

a) Logon to the Azure Portal

b) Navigate to the resource group "export-database"

c) Click on the SQL Server named "export-database-db-server" and click on "Import database" link.















d) Select the BACPAC file from the blob storage








e) Select the "Pricing Tier" as "Standard" and 20 DTUs.


























f) Click OK and the import database would have started.








g) After completion, the "import-database-db" will be under the "SQL Databases" link.







Import using SQLPackage Utility

SQLPackage is a command-line utility that is used to export, import, extract, publish and run T-SQL scripts against databases.

Download the SQLPackage Utility

Check syntax here

Note: SqlPackage.exe will be located under "C:\Program Files\Microsoft SQL Server\150\DAC\bin" post the installation.

For using Windows Authentication, run the following command to get the bacpac file.

sqlpackage.exe /a:Import /sf:export-database-db.bacpac /tdn:import-database-db /tsn:export-database-db-server.database.windows.net /ua:True /tid:"xxxxx.onmicrosoft.com"

For using SQL Authentication, run the following command to get the bacpac file.

sqlpackage.exe /a:import /tcs:"Data Source=export-database-db-server.database.windows.net;Initial Catalog=import-database-db;User Id=xxxxxx;Password=xxxxxx" /sf:export-database-db.bacpac /p:DatabaseEdition=Standard /p:DatabaseServiceObjective=S2

No comments:

Post a Comment