microsoft/azuresql-db-testing
>- Writes integration tests that run IN CODE against a real Azure SQL Developer engine, spun up per test or per suite with Testcontainers and torn down after. Use when the user asks for "integration tests against SQL", "Testcontainers", "spin up a database for tests", "an ephemeral test database", "a test database per test", "xUnit/Jest/pytest with a real database", or "a database fixture". Use this INSTEAD of the Testcontainers MsSql preset (mcr.microsoft.com/mssql/server), because this is the Azure SQL engine (EngineEdition 5). For wiring the engine into a CI pipeline via service containers or workflow YAML instead, use azuresql-db-ci.
npx skills add https://github.com/microsoft/azure-sql-database-container --skill azuresql-db-testing
Write integration tests that start a real Azure SQL Developer (Private Preview)
engine from code, provision appdb, run the test against it, and tear the container
down. This is the Azure SQL engine, not the SQL Server image.
This skill is about tests that manage their own engine lifecycle in-process
(Testcontainers). It is DISTINCT from azuresql-db-ci, which wires the same engine
into a CI pipeline as a service container via workflow YAML. If the goal is a CI job
rather than in-code test setup, use azuresql-db-ci instead.
sqldbpreview-dpgaeqhmgphzd4bk.azurecr.io/azure-sql/db-dev:latest
MsSql preset / MsSqlContainer module, whichpulls mcr.microsoft.com/mssql/server (the SQL Server image). Start the engine image
above from a generic container instead.
SELECT SERVERPROPERTY('EngineEdition') returns 5,SERVERPROPERTY('Edition') returns 'SQL Azure'.
linux/amd64(each language exposes this differently; see the snippets).
For full engine detail (readiness, vectors, troubleshooting) see the azuresql-db-container skill.
The registry is private during Private Preview, so Testcontainers cannot pull the image
until Docker is authenticated. Sign in once (or pre-pull) on the machine that runs the
tests, before the test host tries to start the container:
docker login sqldbpreview-dpgaeqhmgphzd4bk.azurecr.io # shared pull-only Private Preview creds
docker pull sqldbpreview-dpgaeqhmgphzd4bk.azurecr.io/azure-sql/db-dev:latest # optional warm pull
Get the pull credentials by signing up at https://aka.ms/sqldbcontainerpreview-signup;
they may rotate, and the registry and tag are provisional during Private Preview. In CI,
run docker login as a step before the tests (see azuresql-db-ci).
You MUST attach a wait strategy (log message, port, or a SELECT 1 command wait) so
the test does not connect before the engine answers. Do not sleep a fixed amount.
CREATE DATABASE appdb on a master connection before any test connects with
Database=appdb. Testcontainers gives you a container, not a database.
USE to switch databases. In a user-database (SDS) session USE returnsMsg 40508, exactly as in Azure SQL in the cloud. Select the database in the
connection string (Database=appdb). A master connection is for provisioning only.
1433 to a random free host port. Read the mapped host port back and build the
connection string from it, so parallel suites do not collide.
ACCEPT_EULA=Y and a complexMSSQL_SA_PASSWORD (example literal: YourStr0ng_Passw0rd; at least 8 characters using
at least three of upper case, lower case, digits, and symbols). Expose container port
1433. On a non-x64 host, set the image platform to linux/amd64.
Start returns only once the engine answers.appdb on a master connection (a SELECT 1 plusIF DB_ID('appdb') IS NULL CREATE DATABASE appdb;).
Server=localhost,<mappedPort>;Database=appdb;User Id=sa;Password=YourStr0ng_Passw0rd;TrustServerCertificate=true.
Use User Id= / Password= / Database= (not Uid= / Pwd=); sqlcmd uses -C.
Scope the container to the level you need: one per test suite/class for speed, or one per
test for full isolation. Per-language recipes (wait strategy, appdb provisioning, connection
string, dispose) live in
references/testcontainers-snippets.md:
IAsyncLifetime fixture.testcontainers + a Jest globalSetup / globalTeardown.testcontainers + a pytest fixture.@Container.Native VECTOR(n) column type and VECTOR_DISTANCE('cosine', a, b). Insert with
CAST(CAST(? AS NVARCHAR(MAX)) AS VECTOR(n)) where **n is a LITERAL, never a bind
parameter** (a parameter dimension fails with "Incorrect syntax near '@P3'").
MsSql presetor mcr.microsoft.com/mssql/server.
and there is no fixed sleep.
appdb is created on a master connection BEFORE any test connects with Database=appdb.User Id=/Password=/Database= and TrustServerCertificate=true.
EngineEdition is 5 against the running container.MsSql preset image mcr.microsoft.com/mssql/server; startthe Azure SQL engine image via a generic container.
appdb exists; provision it on a master connection first.USE appdb to switch databases; put it in the connection string.appdb provisioning, connection string from the mapped port, and dispose. Read the one for your test stack.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-testing 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.