SQL

Move SQL Server Database to Azure SQL With BACPAC

10 min read

BACPAC import moves a SQL Server database to Azure SQL Database in two steps. You export the schema and the data to one file and then import the file into a new Azure database.

Four ways move the database. A decision table and a list of Microsoft limits show which way fits your database.

Quick SummaryMove a SQL Server database to Azure SQL Database with a BACPAC file in four ways. Export the database with the SSMS wizard and import the file with the second wizard. Use SqlPackage for large or scripted moves. Use the Azure portal when the BACPAC file sits in Blob storage. Use SQL Server Migrator when the export fails on unsupported objects. Stop the application from saving data before the export starts.

What Does a BACPAC File Contain?

BACPAC files contain the schema and the data of one database. Microsoft states that the export builds the schema definition from the current database and then copies the data from all tables.

The file imports into a new database on Azure SQL Database or on another SQL Server instance. The source database must come from SQL Server 2005 SP4 or later.

Heads UpMicrosoft states that you cannot export a database with unsupported DAC objects or with users in it. The Microsoft page for on premises export does not describe transactional consistency. Stop the application from saving data before the export starts.

Which Way Moves Your Database?

Your situation Best way Main limit
You use SSMS and the database is small or medium Method 1 Needs space for a temporary file on the export machine
The database is large or the move needs a script Method 2 Needs the SqlPackage tool on a machine with enough disk space
The BACPAC file already sits in Azure Blob storage Method 3 Single database only and no storage behind a firewall
The export fails on unsupported objects or users Method 4 Exports the objects that the product page lists

What Must Be Ready Before the Import?

Five checks decide whether the import starts. Microsoft documents all five on its page for importing a BACPAC file into Azure SQL Database.

Check What Microsoft states Action
Firewall setting Import and export fail when Allow access to Azure services is off Switch it on or use SqlPackage from an Azure VM
Network port A corporate firewall must open port 1433 Ask the network team before the import
Sign in method SQL authentication and Microsoft Entra ID are the options. Entra ID fails when MFA is required Use SQL authentication for the import
Disk space Portal and PowerShell imports can need up to three times the database size Use SqlPackage on a larger machine for databases over 150 GB
Backup storage Imports default to geo redundant backup storage Check the setting after the import

How Do You Move the Database With a BACPAC File?

Method 1: Use the SSMS Export and Import Wizards

  1. Right click the source database in Object Explorer and select Tasks, then Export Data-tier Application.
  2. Select a folder for the BACPAC file on the Export Settings page. Use the Advanced option to export a subset of tables.
  3. Click Next, then Finish and wait for the results page.
  4. Connect SSMS to the Azure SQL logical server and right click Databases.
  5. Select Import Data-tier Application and select the BACPAC file on the Import Settings page.
  6. Review the database name and size on the Database Settings page and click Finish.

Microsoft adds one tip for export errors. An Out of Disk space failure means the system TEMP and TMP variables point to a full disk. Point both to a separate data disk with free space.

Method 2: Use SqlPackage for Large or Scripted Moves

Microsoft recommends SqlPackage for most production imports. SqlPackage Export creates the BACPAC file and SqlPackage Import creates a new user database from it.

SqlPackage /Action:Export /ssn:SQL01 /sdn:SalesDB /tf:D:\Export\SalesDB.bacpac

SqlPackage /a:import /tcs:"Data Source=<serverName>.database.windows.net;Initial Catalog=SalesDB;User Id=<userId>;Password=<password>" /sf:D:\Export\SalesDB.bacpac /p:DatabaseEdition=Premium /p:DatabaseServiceObjective=P6

The first command exports from the source server. The second command imports into Azure and sets the edition and the service objective. Microsoft advises a higher service tier and compute size during the import and a lower one afterward.

Microsoft names SqlPackage for an import into an elastic pool database. The portal, Azure PowerShell and Azure CLI cannot target a pool. The other route imports into a single database and moves it into the pool.

Method 3: Import the BACPAC File in the Azure Portal

The portal needs the BACPAC file in Azure Blob storage. Upload the file first.

  1. Open the logical server page in the Azure portal and select Import database.
  2. Select Select backup, choose the storage account and select the BACPAC file.
  3. Set the size of the new database and enter the sign in details of the destination server.
  4. Click OK and track the progress under Settings then Import/Export history.
  5. Wait until the status shows Completed and confirm that the database shows Online.

Heads UpMicrosoft states that BACPAC files over 150 GB from SqlPackage can fail in the portal with the message File contains corrupted data. Disk space errors also appear because the import machines have 450 GB of local disk. Use SqlPackage for those files.

Method 4: Move the Database With SQL Server Migrator

Choose SQL Server Migrator when the BACPAC export stops on unsupported objects or users. SQL Server Migrator opens a live SQL Server in online mode or an MDF file in offline mode and exports the schema and the records straight to Azure SQL Database.

SQL Server Migrator exports tables, views, stored procedures, triggers and functions. Logins and Agent tasks remain outside the export. Script them separately.

Download SQL Server Migrator Buy SQL Server Migrator

  1. Install SQL Server Migrator and click Open to add the database.

Open button in SQL Server Migrator

  1. Select Online Mode for a live server and choose Live SQL Server with Authentication. Select Offline Mode to add an MDF file with Quick Scan or Advance Scan.

Live SQL Server selection in SQL Server Migrator

  1. Click Export and select the Azure SQL Database destination. Enter the server details and choose a new or an existing database. Choose With only Schema or With Schema & Data and click Save.

Schema and data export options in SQL Server Migrator

What Do You Check After the Import?

The new database inherits the compatibility level of the source. Raise the level only after you test the application. The post on SQL Server database compatibility level explains the effect on query plans.

SELECT name, compatibility_level, state_desc
FROM sys.databases
WHERE name = N'SalesDB';

SELECT COUNT_BIG(*) AS order_rows
FROM dbo.Orders;

Execute the second query on the source and on the target and compare the numbers. Repeat it for your largest tables. Then create the logins and the users that your application needs on the Azure server.

The guide on migrating SQL Server to Azure cloud shows the replication route for a live system. The post on moving a database to a new server describes a move between two SQL Server instances. The post on SQL Server, Express and Azure SQL explains how the three editions differ.

Which Specifications Does SQL Server Migrator Need?

Compare both tables with your system before you install SQL Server Migrator on the source server or on another workstation.

Software Specifications

Attribute Detail
Software name SQL Server Migrator
Version 6.1.0
Source Live SQL Server in online mode and MDF file in offline mode
Destination SQL Server, Azure SQL Database, MySQL and SQL script files
Objects Tables, views, stored procedures, triggers, functions and others
Export options Schema only or schema with data, new or existing database and primary and foreign keys
SQL Server versions 2025, 2022, 2019, 2017, 2016, 2014, 2012, 2008 R2, 2008, 2005 and 2000
Demo limit Export of 25 records per table and 5 records from every other category

System Specifications

Component Requirement
Processor Intel Core 2 Duo E4600 at 2.40 GHz or equivalent
RAM 4 GB
Hard disk space 100 MB free
Operating system Windows 7, 8 and 10 (32 or 64 bit), Windows 11 (64 bit), Windows Server 2008, 2012 R2, 2016, 2019, 2022 and 2025
Framework Microsoft .NET Framework 4.5 or later
Permission Launch SQL Server Migrator as administrator

Common Questions on BACPAC Import

What Is the Difference Between a BACPAC and a DACPAC File?

A BACPAC file carries the schema and the table data for a move. SqlPackage Export creates it and SqlPackage Import consumes it. A DACPAC file serves schema updates through the Publish action, which updates a database schema to match the file.

Can You Import a BACPAC File Into an Existing Azure Database?

No. Microsoft states that SqlPackage Import creates a new user database from the file. Import into a new database name and then rename it if needed.

How Long Does a BACPAC Import Take?

Microsoft documents no fixed time. It advises you to scale the target database to a higher service tier and compute size during the import and to scale down afterward.

Does the Azure Portal Import a BACPAC File From a Local Disk?

No. The portal needs the BACPAC file in Azure Blob storage. Use SqlPackage or SSMS for a local file.

Why Does the Import Fail With File Contains Corrupted Data?

Microsoft states that BACPAC files over 150 GB from SqlPackage can fail in the portal or in PowerShell with this message. Import the file with SqlPackage instead.

Does SQL Server Migrator Create a BACPAC File?

No. SQL Server Migrator exports the schema and the records from a live server or an MDF file straight to a destination. The product page lists SQL Server, Azure SQL Database, MySQL and SQL script files as destinations.

Who, How and WhyAndrew Jackson, Technical Content Specialist, is the author of this guide. The BACPAC contents, the source version and the export limits follow the Microsoft page on exporting a data-tier application. The portal steps, the 150 GB limit, the disk space note, the firewall rules and the sign in limits follow the Microsoft page on importing a BACPAC file into Azure SQL Database. The wizard pages follow the Microsoft page on importing a BACPAC file. The SqlPackage actions follow the Microsoft page for SqlPackage. The SQL Server Migrator facts come from its product page. The commands and the T-SQL were checked against Microsoft documentation and were not executed on a live server. The guide exists because the limits that stop a BACPAC import sit on three separate Microsoft pages.

Key Takeaways

  • A BACPAC file contains the schema and the data of one database and imports into a new Azure SQL database.
  • Microsoft names unsupported objects and users as export limits. Test the export on a copy.
  • Import fails when Allow access to Azure services is off or when port 1433 is closed.
  • SqlPackage is the way for large files and elastic pools. The portal needs the file in Blob storage.
  • Scale the target up during the import and down afterward, then compare row counts and the compatibility level.
  • SQL Server Migrator moves tables, views, stored procedures, triggers and functions straight to Azure SQL Database when the export fails.