connect-to-azure-sql

Installation
SKILL.md

Connect to Azure SQL Database

Opening one connection is easy. Two things go wrong: the first connection is expected to fail and the code has no retry, and a certificate error gets fixed by turning verification off.

Connect once from the command line before writing any code

Settle the server, database, credential and certificate before an application is in the picture, so every later failure is a failure of the code. Cloud, SQL authentication, password out of the command line:

export SQLCMDPASSWORD="$SQL_PASSWORD"   # sqlcmd reads it from the environment; no -P in the process list
sqlcmd -S <server>.database.windows.net,1433 -d <database> -U <user> \
  -N mandatory -l 30 -Q "SELECT DB_NAME() AS db, encrypt_option FROM sys.dm_exec_connections WHERE session_id = @@SPID"

Cloud, Microsoft Entra ID, with no password anywhere:

Installs
53
GitHub Stars
66
First Seen
Sep 28, 2026