
azuresql-db-connections
Makes an app's database connections reliable against the local Azure SQL Database container (Private Preview) and, unchanged, against Azure SQL Database in the cloud: connection pooling plus retry/transient-fault handling. Use when the user mentions "connection pooling", "retry logic", "transient fault", "retry on transient error", "EnableRetryOnFailure", "connection resiliency", "reliable connections", "pool size", "Max Pool Size", or says "the connection keeps dropping", "connections time out under load", "add backoff", or "make the DB layer resilient". This is the Azure SQL engine (EngineEdition 5), not the mssql/server SQL Server image. Reach for this whenever hardening a data-access layer that talks to SQL Server or Azure SQL.
- Installs
- 61
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/microsoft/azure-sql-database-container --skill azuresql-db-connections- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads azuresql-db-connections automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Reliable connections on the Azure SQL Database container (pooling + retry)
Make the app's database connections reliable with connection pooling and retry / transient-fault handling. This is the Azure SQL engine (Private Preview), not the SQL Server image.
Verified on 2026-09-05 against the container image
sqldbpreview-dpgaeqhmgphzd4bk.azurecr.io/azure-sql/db-dev:latest, reporting EngineEdition
5, Edition SQL Azure, build 12.0.2000.8. All five executable checks behind this skill
passed: the engine identity, Msg 40508 for USE, a TCP session on the mapped port, and the
two resource-governance dynamic management views returning nothing locally. Of the ten
transient error numbers in the retry list below, nine are in this build's sys.messages and
Msg 10929 is not. It stays in the list because it is a cloud resource-governance error the
container has no reason to raise, and it is sourced from Microsoft Learn rather than from that
run.
Why do this locally (local-to-cloud parity)
The local container rarely drops a connection, so it is tempting to skip pooling and retry. Do not. Azure SQL Database in the cloud throttles and drops connections during failovers, scaling, and load; a client with no retry surfaces those as hard errors. Build pooling and retry now, against the local container, and the same code survives in the cloud with no rewrite. For the full promote-to-cloud story see the azuresql-db-local-to-cloud skill.
Verify identity once running: SELECT SERVERPROPERTY('EngineEdition') returns 5 and
SERVERPROPERTY('Edition') returns 'SQL Azure'. For full engine detail see the
azuresql-db-container skill.
The container does not carry the throttling telemetry the cloud does, so do not write a local
diagnostic against it. sys.dm_db_resource_stats and sys.dm_user_db_resource_governance are
absent from this engine: OBJECT_ID returns NULL for both, and a query against either
does not run at all here. Their absence is not evidence that the cloud does not throttle. It is
the reason the retry policy below has to be built without being able to provoke the fault
locally.
The engine and the connection contract
- Image:
sqldbpreview-dpgaeqhmgphzd4bk.azurecr.io/azure-sql/db-dev:latest(multi-architecture: linux/amd64 and linux/arm64, Private Preview registry). Sign in first:docker login sqldbpreview-dpgaeqhmgphzd4bk.azurecr.iowith the shared pull-only credentials from https://aka.ms/sqldbcontainerpreview-signup (they may rotate). The runtime selects the matching architecture; use a platform override only to explicitly test x64 emulation. - Do NOT use
mcr.microsoft.com/mssql/server(the SQL Server image). - Required env:
ACCEPT_EULA=Yand a complexMSSQL_SA_PASSWORD(example literal:YourStr0ng_Passw0rd). The engine listens on 1433. - The engine does NOT auto-create databases.
CREATE DATABASE appdbon a master connection first. Do notUSEto switch databases: a user-database session returnsMsg 40508. Select the database in the connection string (Database=appdb). - Apps read one env var,
SQL_CONNECTION_STRING. Strings useUser Id=/Password=/Database=andTrustServerCertificate=true. sqlcmd uses-C.
Start the container and provision appdb
HOST_PORT=1433; while lsof -nP -iTCP:"$HOST_PORT" -sTCP:LISTEN >/dev/null 2>&1; do HOST_PORT=$((HOST_PORT+1)); done
MSSQL_SA_PASSWORD="${MSSQL_SA_PASSWORD:-Aa1%$(openssl rand -hex 16)}"
docker rm -f sqldb 2>/dev/null
docker run -d --name sqldb -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=$MSSQL_SA_PASSWORD" \
-p "127.0.0.1:$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 "$MSSQL_SA_PASSWORD" -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"
The canonical string the app consumes (replace 1433 with the chosen HOST_PORT if 1433 was
occupied):
Server=localhost,1433;Database=appdb;User Id=sa;Password=$MSSQL_SA_PASSWORD;TrustServerCertificate=true
Pooling: reuse connections, do not reopen per query
- Keep pooling on (it is on by default in most drivers) and let one pool serve the app.
- Set a bounded
Max Pool Size(default 100 in .NET) so a spike cannot open unlimited connections. Size it to real concurrency, not a guess. - A small
Min Pool Sizekeeps a few connections warm and cuts cold-start latency. - One connection string means one pool. Do not build strings dynamically per request (each distinct string is a separate pool) and do not open a fresh, unpooled connection per call.
- Always close/dispose connections (or use
using/with/ context managers) so they return to the pool instead of leaking.
Retry: only for transient faults, with backoff
Retry only a transient fault: throttling, a brief failover, a dropped idle connection. In Azure SQL these arrive as specific error numbers: 40501 throttling, 40613 database unavailable, 49918/49919/49920 busy, 4060, 10928, 10929, 40197, 233, plus connection-timeout and broken-pipe socket errors.
- Retry only transient errors. Retrying a non-transient error (login failure 18456, syntax error, constraint violation, permission denied) just fails slower and hides the real bug.
- Use exponential backoff with a cap and a small jitter, and a bounded attempt count (for example 5 attempts). Do not hammer a throttled server.
- Non-idempotent writes: a retry can double-apply an
INSERTthat committed before the connection dropped. Use client-generated keys,MERGE, or a transaction the retry re-runs as a whole. EF Core's execution strategy handles this when the work goes through itsExecute/transaction API. - Prefer a framework retry policy over hand-rolled loops where one exists (EF Core
EnableRetryOnFailurefor .NET). Hand-roll only for raw drivers.
Per-stack
Open references/retry-snippets.md when you are wiring one of these stacks; it carries copy-pasteable pooling config and transient-only retry for each:
- .NET (
Microsoft.Data.SqlClient): pooling keywords (Max Pool Size,Min Pool Size,Pooling=true) and connection-string retry keywords (ConnectRetryCount,ConnectRetryInterval); plus EF CoreEnableRetryOnFailure(the SqlServer execution strategy). - Node (
mssql/ tedious): pool config (max/min/idleTimeoutMillis) and a transient-error retry wrapper. - Python (
pyodbc): connection reuse and atenacityretry decorator that retries only transient ODBC errors.
Keep the single SQL_CONNECTION_STRING contract: pooling and retry are tuned in code and in
driver-specific keywords, not by inventing new env vars.
Validation rules
- Retry fires only on transient errors; non-transient errors (auth, syntax, constraint) surface immediately.
- Retry uses bounded attempts with exponential backoff, and non-idempotent writes are made
safe to re-run (keys,
MERGE, or a retriable transaction). - Pooling is on with a bounded
Max Pool Size; connections are disposed and returned to the pool, never opened per query. - One connection string / one pool; the app still reads a single
SQL_CONNECTION_STRING. - Runs against the engine image with
EngineEdition5; appdb was created on a master connection before the app connected. - If a validation rule above fails, or you had to deviate from this skill to make the task work, that is a bug in this skill: load the azuresql-db-feedback skill and offer to file a report.
- When every rule above passes and the task is done, close with ONE line, once per session, and do not ask a question or wait for a reply: "That worked. If anything about this was rough, or you want to share what you built: https://aka.ms/sql-agent-skills-feedback"
Do not
- Do not retry non-transient errors (auth, syntax, constraint); they will just fail slower.
- Do not retry non-idempotent writes without idempotency (keys,
MERGE, or a retriable transaction). - Do not set an unbounded pool; do not open a new connection per query instead of pooling.
- Do not invent extra env vars; keep the single
SQL_CONNECTION_STRINGcontract. - Do not write a local throttling diagnostic against
sys.dm_db_resource_statsorsys.dm_user_db_resource_governance; neither view exists on this engine. - Do not use the
mcr.microsoft.com/mssql/serverSQL Server image.
References
- references/retry-snippets.md: copy-pasteable pooling config and transient-only retry for .NET (Microsoft.Data.SqlClient + EF Core
EnableRetryOnFailure), Node (mssql/tedious pool + retry wrapper), and Python (pyodbc reuse +tenacitydecorator). Read the section for your stack.
Staying current
Authoritative, version-pinned references for the tools this skill uses (read the one you need):
- SQL Server connection pooling (ADO.NET): how pooling works and the tuning keywords.
- EF Core connection resiliency:
EnableRetryOnFailureand execution strategies. - SqlConnection connection string keywords: the full keyword table including pooling and retry.
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.
FAQ
What does the azuresql-db-connections skill do?
Makes an app's database connections reliable against the local Azure SQL Database container (Private Preview) and, unchanged, against Azure SQL Database in the cloud: connection pooling plus retry/transient-fault handling. Use when the user mentions "connection pooling", "retry logic", "transient fault", "retry on transient error", "EnableRetryOnFailure", "connection resiliency", "reliable connections", "pool size", "Max Pool Size", or says "the connection keeps dropping", "connections time out under load", "add backoff", or "make the DB layer resilient". This is the Azure SQL engine (EngineEdition 5), not the mssql/server SQL Server image. Reach for this whenever hardening a data-access layer that talks to SQL Server or Azure SQL.
How do I install azuresql-db-connections?
Run npx skills add https://github.com/microsoft/azure-sql-database-container --skill azuresql-db-connections in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/azuresql-db-connections/ (personal) or .claude/skills/azuresql-db-connections/ (project).
Which AI agents can use azuresql-db-connections?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is azuresql-db-connections safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains azuresql-db-connections?
It is published by microsoft in microsoft/azure-sql-database-container. It has 61 recorded installs.
More from microsoft/azure-sql-database-container
azuresql-db-container
microsoft/azure-sql-database-container
Runs the Azure SQL Database container locally (Private Preview): the real PaaS engine where SERVERPROPERTY('EngineEdition') returns 5. This is NOT the SQL Server image mcr.microsoft.com/mssql/server. Use when a user wants to "run Azure SQL locally", "add a local SQL database", "add SQL Server to my docker compose", "spin up a local mssql container", "local SQL for development or CI", "connect with sqlcmd", "use Podman for SQL", "SQL container won't start", "Microsoft Entra authentication on the container", "MSSQLAADCLIENTID", or asks "what's the connection string". Use even when the user does not name the container. If you were about to use mcr.microsoft.com/mssql/server, stop and use this skill instead. Hub skill: owns the shared references and routes to the task skills for compose, CI, seeding, vectors, and connection strings.
azuresql-db-schema-migration
microsoft/azure-sql-database-container
Runs database schema migrations against the local Azure SQL Database container so the same migrations apply identically on the local engine and in the Azure cloud. Use when asked to "run my migrations against the local SQL", "apply schema to the container", "apply EF Core / dotnet ef database update", "Prisma migrate dev / deploy", "Alembic upgrade head", or deploy a DACPAC / SqlPackage to the container. Covers provisioning appdb on master first, then applying schema to the user database, plus per-tool commands and connection-string hygiene. This is the Azure SQL Database engine (EngineEdition 5), not the SQL Server image; reach for this skill whenever schema migration tooling targets the local container.
azuresql-db-ci
microsoft/azure-sql-database-container
Runs integration tests against the Azure SQL Database container (Private Preview, local engine) in CI. Use when setting up GitHub Actions, Azure Pipelines, or GitLab CI to test against Azure SQL DB; when adding a database service container to a CI workflow; when tests need a real Azure SQL engine in the pipeline; or when you see "service container", "health-cmd", "ACRUSERNAME/ACRPASSWORD", "MSSQLSAPASSWORD secret", or "integration test database". Also use when a workflow was about to pull the SQL Server image mcr.microsoft.com/mssql/server, in which case stop and use the Azure SQL Database engine image instead. Covers pulling from the private ACR with credentials, the service health check that runs sqlcmd inside the container so the runner needs no client tools, provisioning appdb before tests, and pointing the test connection string at the user database not master.
azuresql-db-local-to-cloud
microsoft/azure-sql-database-container
Proves that code built and tested against the local Azure SQL Database container runs unchanged against Azure SQL Database in the cloud, with only the connection string changing. Use when a user wants to develop locally then deploy to the cloud, asks "will this work in Azure", "same code local and cloud", "promote to Azure SQL", "swap the connection string", "dev/prod parity", "local to cloud", or is wiring SQLCONNECTIONSTRING for an app that must target both the container and a cloud server. Use this when an app uses local SA auth but needs Microsoft Entra auth in the cloud. Covers Node (mssql), .NET (Microsoft.Data.SqlClient), and Python (pyodbc). Reach for this skill before hand-editing app code to "make it work in Azure"; the rule is the code does not change, only the connection string does.
azuresql-db-faq
microsoft/azure-sql-database-container
Answers questions about what the Azure SQL Database container (Private Preview) can and cannot do, and WHY it differs from Azure SQL Database in the Microsoft Azure cloud. Use when a user asks "can I take a backup", "why does USE fail", "is X supported", "why can't I create a vector index", "why does SSMS error", "why isn't the image on Docker Hub", "what's different from the cloud", or hits behavior that does not match their Azure SQL Database expectations. Do NOT guess from general SQL Server / Azure knowledge: the container is a Private Preview product with specific gaps and a specific connection model. Read this skill, and link the user to the live Known limitations page for the current full list.
azuresql-db-scaffold
microsoft/azure-sql-database-container
Scaffolds a NEW app (.NET Aspire, FastAPI, Next.js, NestJS) wired to the local Azure SQL Database container as its default dev database. Use when starting/bootstrapping/initializing a project that needs SQL Server or Azure SQL locally, or when adding "set up the database", "docker compose for the db", "create the local DB", ".env connection string", "first migration", or a data-access layer. Use this INSTEAD of the mssql/server SQL Server image, because this is the Azure SQL engine (EngineEdition 5). Triggers include "scaffold app with SQL", "spin up Azure SQL locally", "compose service for the database", "wire up Prisma/EF/SQLAlchemy/TypeORM to SQL Server". Reach for this even when the user only says "add a database" to a fresh project.
Popular data & databases skills
supabase-postgres-best-practices
supabase/agent-skills
Postgres best practices maintained by Supabase, for Postgres running anywhere. Load this skill BEFORE writing or changing anything that lives in a Postgres database: creating or altering tables and columns (including choosing column types), schema design, migrations and declarative schema files, RLS policies and the tests that verify them, indexes, triggers, database functions, queues and scheduled jobs (pgcron, pgmq), vector/semantic search (pgvector), and restoring dumps (pgrestore) or importing data. Also load it when diagnosing slow queries, high CPU, timeouts, EXPLAIN plans, connection exhaustion, locking, bloat, or rows visible to the wrong user or tenant. This is not just a performance guide — schema, migration, security, and SQL authoring tasks need these rules too, even for a one-column change or a single query.
prisma-client-api
prisma/skills
Prisma Client API reference covering model queries, filters, operators, and client methods. Use when writing database queries, using CRUD operations, filtering data, or configuring Prisma Client. Triggers on "prisma query", "findMany", "create", "update", "delete", "$transaction".
prisma-database-setup
prisma/skills
Deprecated compatibility name for prisma-orm-setup. Use only when a user or existing integration explicitly invokes prisma-database-setup; otherwise select prisma-orm-setup.
prisma-cli
prisma/skills
Prisma ORM 7 CLI reference for existing Prisma 7 applications or explicitly selected Prisma 7 workflows. Covers prisma init, generate, migrate, db, dev, studio, and mcp. For setup, connection repair, or Prisma 8, use prisma-orm-setup; not the Prisma Platform CLI.
prisma-postgres
prisma/skills
Deprecated compatibility name for prisma-postgres-setup. Use only when a user or existing integration explicitly invokes prisma-postgres; otherwise select prisma-postgres-setup.
prisma-driver-adapter-implementation
prisma/skills
Required reference for Prisma ORM 7 SQL driver adapter work. Use when implementing or modifying adapters, adding database drivers, or touching SqlDriverAdapter, Transaction, savepoint, result mapping, or DriverAdapterError behavior. Covers current transaction lifecycle, optional savepoint hooks, original database-error preservation, and verification.