microsoft/azuresql-db-import
>- Imports an existing Azure SQL Database or SQL Server schema and data INTO the local Azure SQL Developer using SqlPackage. Use when asked to "import a bacpac", "load my existing database locally", "restore a dacpac into the container", "bring my prod schema into the dev container", "run my .bacpac/.dacpac against the local Azure SQL engine", or migrate an existing database into the preview container. Handles provisioning the target database provisioned user database. Use this for any "get my real database running in the container" request instead of hand-writing SqlPackage flags.
npx skills add https://github.com/microsoft/azure-sql-database-container --skill azuresql-db-import
Bring an existing database INTO the local Azure SQL Developer from a
.bacpac (schema + data) or .dacpac (schema only) using SqlPackage.
This is the Azure SQL Database engine running locally (Private Preview):
SELECT SERVERPROPERTY('EngineEdition') returns 5 and Edition returns
'SQL Azure'. It is NOT the SQL Server image
mcr.microsoft.com/mssql/server. If you were about to use that SQL Server image, stop
and use this instead.
sqldbpreview-dpgaeqhmgphzd4bk.azurecr.io/azure-sql/db-dev:latest(x64, linux/amd64; private preview registry, sign in first). Registry/tag are
provisional during Private Preview.
--platform linux/amd64.CREATE DATABASE appdbon a master connection before importing into it.
USE to switch databases. In a user-database (SDS) session (theAzure-faithful context where you develop), USE returns Msg 40508, exactly as
in Azure SQL Database in the cloud. A master connection is a non-SDS
provisioning session where the Azure statement filter is not enforced, so USE appears to work there, but master is for provisioning
only, not application work. Always select the target database in the connection
string (Database=appdb, or -d appdb for sqlcmd).
For full container detail (start recipe, connection model, readiness), see the
azuresql-db-container skill. The minimum you need is inlined below.
/Action:Import targeting the provisioned user database.This is the Private Preview supported import path. Always validate the result.
Reuse the canonical start recipe. It picks a free host port, adds --platform
only on a non-x64 host, waits for readiness with a retry loop, and provisions the
target database appdb on master in that same loop.
# Pick a free host port and add the platform flag only on a non-x64 host (works in bash and zsh).
HOST_PORT=1433; while lsof -nP -iTCP:"$HOST_PORT" -sTCP:LISTEN >/dev/null 2>&1; do HOST_PORT=$((HOST_PORT+1)); done
PLATFORM=(); case "$(docker info -f '{{.Architecture}}' 2>/dev/null)" in x86_64|amd64) ;; *) PLATFORM=(--platform linux/amd64);; esac
docker rm -f sqldb 2>/dev/null
docker run -d --name sqldb "${PLATFORM[@]}" -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=YourStr0ng_Passw0rd" \
-p "$HOST_PORT:1433" sqldbpreview-dpgaeqhmgphzd4bk.azurecr.io/azure-sql/db-dev:latest
until docker exec sqldb /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P "YourStr0ng_Passw0rd" -C -b -l 2 \
-Q "IF DB_ID('appdb') IS NULL CREATE DATABASE appdb;" >/dev/null 2>&1; do sleep 2; done
echo "ready on localhost,$HOST_PORT"
If the container is already running, just provision the target database on master:
docker exec sqldb /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P "YourStr0ng_Passw0rd" -C -b \
-Q "IF DB_ID('appdb') IS NULL CREATE DATABASE appdb;"
> The target database MUST exist and be empty before import. SqlPackage imports
> the user database; it does not create it on the server for you here.
Point /TargetConnectionString at the provisioned database (Database=appdb).
Use the canonical connection string shape: User Id=/Password=/Database=,
TrustServerCertificate=true.
Schema + data (.bacpac):
SqlPackage /Action:Import \
/SourceFile:"./mydatabase.bacpac" \
/TargetConnectionString:"Server=localhost,$HOST_PORT;Database=appdb;User Id=sa;Password=YourStr0ng_Passw0rd;TrustServerCertificate=true"
Schema only (.dacpac) uses /Action:Publish, not Import:
SqlPackage /Action:Publish \
/SourceFile:"./myschema.dacpac" \
/TargetConnectionString:"Server=localhost,$HOST_PORT;Database=appdb;User Id=sa;Password=YourStr0ng_Passw0rd;TrustServerCertificate=true"
If SqlPackage is not installed locally, see references/sqlpackage-import.md for
install options and a container-based fallback.
Confirm the engine identity and spot-check that objects landed:
docker exec sqldb /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P "YourStr0ng_Passw0rd" -C -b -d appdb \
-Q "SELECT SERVERPROPERTY('EngineEdition') AS EngineEdition; SELECT COUNT(*) AS Tables FROM sys.tables;"
EngineEdition must be 5. Then verify row counts on a few key tables against
the source.
This engine is Azure SQL Database (Engine Edition 5), so SQL Server features
that Azure SQL DB does not support will fail or be skipped on import:
USE <db> in scripts: avoid USE to switch databases. In a user-database(SDS) session (the Azure-faithful context where you develop), USE returns
Msg 40508, exactly as in Azure SQL Database in the cloud. A master connection
is a non-SDS provisioning session where the Azure statement filter is not
enforced, so USE appears to work there, but master is
for provisioning only, not application work. Always select the target database in
the connection string (Database=appdb, or -d appdb for sqlcmd).
filestream, certain CLR and filegroup/physical-file settings.
DATABASE_DEFAULT collation assumptions and unsupportedcompatibility-level features.
Read SqlPackage output for skipped/blocking items. See
references/sqlpackage-import.md for the common error patterns and fixes.
/TargetConnectionString sets Database=appdb (never the literal master).SERVERPROPERTY('EngineEdition') on the target is 5..bacpac for schema + data via /Action:Import; .dacpac for schema via/Action:Publish.
mcr.microsoft.com/mssql/server SQL Server image.master; import into the provisioned user database.USE appdb in any pre/post script; select the DB in the connectionstring instead.
/docker-entrypoint-initdb.d/*.sql auto-seeding; it is NOThonored by this image.
--platform linux/amd64on a non-x64 host.
docker run as "ready"; provision inside the retry loop.container-based fallback, and common import errors with fixes. Read it when SqlPackage is missing or an import fails.
Authoritative, version-pinned references for the tools this skill uses (read the one you need):
If the Microsoft Learn MCP server is configured, use mcp__microsoft-learn__microsoft_docs_search or mcp__microsoft-learn__microsoft_docs_fetch to fetch the current version of any of these on demand. It is optional; when it is unavailable, the references above are authoritative.
Take microsoft/azuresql-db-import from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.
The instructions reference docker.
Without those the skill loads but fails at the first command.