One of the most common concerns customers raise is: “My BACPAC import to Azure SQL Database is running slow. How long will it take?”
This is a frequent scenario, especially when migrating large databases to Azure. The truth is, the time taken for a BACPAC import depends on several factor: database size, compute tier, network latency, and the tools used for the import.
Things we already know so far:
- Imports run fastest using the SqlPackage utility compared to SSMS or the Azure Portal.
- SSMS and Portal-based imports are convenient but slower as they involve additional overhead and limited control over performance parameters.
- SqlPackage offers advanced options like parallelism and index handling, which can drastically improve speed when configured correctly.
In this blog, we’ll explore and walk through a step-by-step optimized approach to make them faster.
Step #1
Create a Blank Target Database
Before starting the import, create a new empty database on the target Azure SQL Server.
This ensures you have a destination ready for the BACPAC import.
Step#2
Scale Up the Target Database
Import performance depends heavily on compute and IOPS.
Action: Scale the target database to the highest ‘feasible’ available tier – preferably Premium, Business Critical, or Hyperscale.
This provides, High CPU and memory for processing – plus increased IOPS for faster data load.
Cost Tip: Charges apply only during the import period. After completion, scale down to a lower tier.
Approval: Get prior approval for temporary scaling to avoid unexpected costs. [IMP]
Step#3
Use an Azure VM in the Same Region
Create or use an Azure Virtual Machine with:
- High CPU (e.g., D16ds_v4 or better).
- SSD storage with high IOPS.
Why pick the same region?
- Reduces latency between VM and Azure SQL Database.
- Speeds up data transfer during import.
Step#4
Install and Run SqlPackage on the VM
- Download SqlPackage (latest 64-bit version) from Microsoft.
- Run the import from the VM:
sqlpackage.exe /Action:Import /tsn:tcp:MyServer.database.windows.net,1433 /tdn:StackOverFlow /tu:AdminUser /tp:AdminPassword1 /sf:C:\temp\SO.bacpac
Step#5
Optimize Import Parameters
Use these parameters for better performance:
- /p:DisableIndexesForDataPhase=False
- Keeps indexes enabled during data load.
- Best for small to medium databases (avoids index rebuild overhead).
- /p:MaxParallelism=32
- Enables parallel processing using multiple threads.
- Adjust based on VM CPU cores.
Example:
sqlpackage.exe /Action:Import /tsn:tcp:MyServer.database.windows.net,1433 /tdn:StackOverFlow /tu:AdminUser /tp:AdminPassword1 /sf:C:\temp\SO.bacpac /p:DisableIndexesForDataPhase=False /p:MaxParallelism=32