/microsoft-sql-vscode:azure-functions-sql-bindingsfrom Microsoft SQL for Visual Studio Code
Wires Azure Functions to Azure SQL Database with input/output bindings and SqlTrigger. Prevents silent trigger failures caused by missing change tracking prerequisites.
Ships in Microsoft SQL for Visual Studio Code. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Two bindings and a trigger. The bindings are straightforward. The trigger has a prerequisite that fails without failing the app, which is what this skill exists for.
| Question | Skill |
|---|---|
| Reusing a connection across invocations, pool sizing, retry | connect-from-dotnet, connect-from-python, connect-from-typescript-and-node |
| Getting the identity to a working passwordless connection | entra-id-auth |
| Publishing the app and its infrastructure | deploy-app-to-azure |
The bindings open their own connections, so that pooling advice is about code you write inside the function.
func init todo-fn --worker-runtime dotnet-isolated
cd todo-fn || exit 1
dotnet add package Microsoft.Azure.Functions.Worker.Extensions.Sql
Learn sets v3.1.284 as the package floor for Consumption plans, and the current package is above it. Two things the tooling does not tell you:
Core Tools 4.12 scaffolds net10.0. On a .NET 8 SDK the next restore fails with
error NETSDK1045: The current .NET SDK does not support targeting .NET 10.0. Set
<TargetFramework> to a version your SDK has before you add the package.
func new cannot create the SQL functions, though func templates list advertises them. With
Core Tools 4.12 the template name loses its spaces and is then rejected:
func templates list | grep 'SQL Trigger'
func new --template "SQL Trigger" --name ToDoTrigger
The first prints SQL Trigger. The second fails with
Unknown template 'SQLTrigger' (Parameter 'templateName'), as do SqlTrigger, SQLTrigger and
SQL Input Binding. HTTP trigger succeeds in the same command, so a working func new proves
nothing about the SQL templates. Write the attribute by hand.
The trigger is built on SQL change tracking. At startup the listener asks the database for
CHANGE_TRACKING_MIN_VALID_VERSION(<table-id>), which Learn documents as returning null when
change tracking is off for the database, the object id is invalid, or permission to the table is
insufficient. The listener throws on that null, before it polls once.
What that looks like from outside is nothing. The host catches it and restarts that one listener with exponential backoff, which Learn documents as startup retries. The app starts, reports healthy, keeps serving every other function. The trigger never fires, and the only evidence is one error line naming the listener rather than the missing feature. So change tracking is step one, not a tuning step.
Two statements. Enabling it on the database does not enable it on any table, and the table statement fails if the database is not enabled first.
ALTER DATABASE CURRENT
SET CHANGE_TRACKING = ON
(CHANGE_RETENTION = 2 DAYS, AUTO_CLEANUP = ON);
ALTER TABLE [dbo].[ToDo]
ENABLE CHANGE_TRACKING;
CHANGE_RETENTION defaults to 2 days and is how far back the trigger catches up; an app stopped
longer loses the older changes. AUTO_CLEANUP = OFF pauses that removal while diagnosing a stalled
trigger. These options cannot be combined with other ALTER DATABASE options in one statement,
which fails with Msg 22114.
The monitored table must have a primary key. Without one the second statement fails with
Msg 4997, Cannot enable change tracking on table '<name>'. Change tracking requires a primary key on the table. That is the number in the local Azure SQL Database container, not the Msg 22119 you
may find quoted for this refusal, so a deployment log grepped for 22119 finds nothing. The cloud
service may report a different number, so match on the text when you read a log from Azure SQL
Database.
The trigger receives a batch of changes, each carrying the changed item and the operation
(Insert, Update, Delete). This compiles as written:
[Function("ToDoTrigger")]
public static void Run(
[SqlTrigger("[dbo].[ToDo]", "SqlConnectionString")]
IReadOnlyList<SqlChange<ToDoItem>> changes,
FunctionContext context)
{
foreach (SqlChange<ToDoItem> change in changes)
{
context.GetLogger("ToDoTrigger").LogInformation(
"{Operation} on {Id}", change.Operation, change.Item.Id);
}
}
Open references/bindings-by-language.md before writing this declaration in anything but C#: the attribute name, argument casing and package change per language, and nothing else does.
Changes are batched per row, not per statement. A row written three times between two polls arrives as one entry, showing the difference between the last processed state and now. Anything needing every intermediate value needs another mechanism.
db_datareader and db_datawriter are enough for the input and output bindings. Microsoft's
wording is that they are not sufficient for the trigger, which reads change tracking and keeps
its own state and leases tables in an az_func schema it creates if absent.
GRANT CREATE TABLE TO [<identity-name>];
GRANT CREATE SCHEMA TO [<identity-name>];
GRANT SELECT ON [dbo].[ToDo] TO [<identity-name>];
GRANT VIEW CHANGE TRACKING ON [dbo].[ToDo] TO [<identity-name>];
GO
CREATE SCHEMA az_func;
GO
GRANT ALTER ON SCHEMA::az_func TO [<identity-name>];
GRANT SELECT, INSERT, UPDATE, DELETE ON SCHEMA::az_func TO [<identity-name>];
Missing these fails the same way: a listener that will not start, an app that looks fine.
The input binding runs a query or stored procedure and hands the rows to the function. Parameters are bound, not interpolated, which keeps a route value out of the SQL text:
[SqlInput(
commandText: "SELECT [Id], [title] FROM dbo.ToDo WHERE Id = @Id",
commandType: System.Data.CommandType.Text,
parameters: "@Id={Query.id}",
connectionStringSetting: "SqlConnectionString")]
IEnumerable<ToDoItem> todo
parameters is one string of the form @a=1,@b=2. No name or value may contain a comma or an
equals sign, a real limit binding free text.
The output binding takes an object or a collection and a table name:
[SqlOutput("dbo.ToDo", connectionStringSetting: "SqlConnectionString")]
public ToDoItem ToDoItem { get; set; }
It upserts. Learn states the output bindings use T-SQL MERGE, so a write whose key already
exists updates that row rather than failing, and code that treats the binding as an insert will
report a create that was an overwrite. MERGE also needs SELECT on the target, not only
INSERT.
Two limits. Columns typed NTEXT, TEXT or IMAGE are unsupported and the upsert fails, because
they are incompatible with the OPENJSON the binding builds its MERGE from. And an
exception in the binding stops the function, so an HTTP trigger returns 500 unless
IAsyncCollector is used and FlushAsync awaited inside a try block.
connectionStringSetting names an application setting, not a connection string. Locally it
lives in local.settings.json, which never goes into source control. In Azure it is an app setting
whose value carries an identity:
Server=<server-name>.database.windows.net; Authentication=Active Directory Default; Database=<database-name>; User Id=<client-id-of-user-assigned-identity>
Learn's managed identity tutorial states Active Directory Default resolves to developer
credentials locally and the managed identity in Azure, so one string serves both, and that
User Id is omitted for a system-assigned identity. The bindings overview page shows
Active Directory Managed Identity instead; both are valid, only the first also works locally.
The identity needs a database user:
CREATE USER [<identity-name>] FROM EXTERNAL PROVIDER;
ALTER ROLE db_datareader ADD MEMBER [<identity-name>];
ALTER ROLE db_datawriter ADD MEMBER [<identity-name>];
GO
<identity-name> is the identity's own name for a user-assigned identity, the function app's name
for a system-assigned one. If a trigger is in play, add the grants from step 3 on top.
MaxBatchSize defaults to 100, PollingIntervalMs to 1000 and MaxChangesPerWorker to 1000, all
under extensions.Sql in host.json. On a Premium plan, scaling out on pending change count needs
runtime scale monitoring:
az resource update -g <resource-group> -n <function-app-name>/config/web \
--set properties.functionsRuntimeScaleMonitoringEnabled=1 \
--resource-type Microsoft.Web/sites
A batch that throws is retried after 60 seconds; a row failing five times in a row is ignored for all future changes. A poison row is skipped, not queued behind, so log the key on failure or the loss is invisible.
Change tracking is provable from SQL alone, before the app runs. Two rows back, one per query, or the trigger does not start:
sqlcmd -S <server-name>.database.windows.net -d <database-name> -G -Q \
"SELECT DB_NAME() AS db, is_auto_cleanup_on, retention_period, retention_period_units_desc
FROM sys.change_tracking_databases WHERE database_id = DB_ID();
SELECT OBJECT_NAME(object_id) AS tracked_table FROM sys.change_tracking_tables;"
An empty second result set is the common failure: the database statement looks done. Then confirm
what the listener reads, a number rather than NULL once both statements have run:
SELECT CHANGE_TRACKING_MIN_VALID_VERSION(OBJECT_ID('dbo.ToDo')) AS min_valid_version;
Only then read the host log: Started SQL trigger listener for table is the success line, and
Failed to start SQL trigger listener on a healthy app is this skill's subject. Finally,
write the same primary key twice through the output binding. Two 201 responses and one row
confirms the MERGE.
db_datareader and db_datawriter to a trigger identity.az_func tables by hand or rename them. The trigger owns them.MERGE on the primary key.func new here, or read a name in func templates list as proof it scaffolds.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub microsoft/microsoft-sql --plugin microsoft-sql-vscode44 skills in this plugin
/authentication-diagnosticsUse when a login fails (18456, 'Login failed for user'), a user can't open a database, a permission is denied, or an Entra or managed identity login fails. For network errors, use `connectivity-troubleshoot`./bulk-load-and-bulk-copyUse when loading a large file or many rows into an Azure SQL Database table fast: bulk insert a CSV, bcp, SqlBulkCopy, fast_executemany, BULK INSERT or OPENROWSET refusing a local file (Msg 12713), LOG_RATE_GOVERNOR./check-live-blockingUse when queries hang right now: who is blocking, the head blocker, why a blocking DMV looks empty. Has tested queries and rules common answers miss, e.g. a sleeping head blocker is absent from sys.dm_exec_requests. For past blocking, use read-only blocking root-cause investigation using the host SQL tools.2 plugins in one repository ship this exact skill · first indexed Nov 20, 2026
Other plugins' skills for the same job