Azure PostgreSQL TypeScript Connector
A practical pg-based guide for secure, pooled Azure PostgreSQL access in Node.js and TypeScript.
The document uses parameterized queries, TLS verification, Entra ID passwordless authentication, and environment variables, with no evidence of malware, exfiltration, or destructive defaults. It does not fully specify confirmation boundaries for writes, secret-handling and logging risks, sensitive connection-string handling, least-privilege database roles, or recovery procedures, so points are deducted.
Single-client, pooling, transaction, cleanup, timeout, and error-handling paths are documented. However, the token-refresh example uses QueryResult and PoolClient without importing them, pool replacement has concurrency and checked-out-connection edge cases, and no skill-specific tests or statically verifiable abnormal-input coverage are provided. The score remains conservative under the static-review ceiling.
The name, audience, Node.js/TypeScript setting, and trigger terms are clear, covering password auth, Entra ID, pooling, transactions, and typed queries. Non-fit scenarios, required Azure-side setup, database permission boundaries, and Chinese-language guidance are not stated, so adaptability is reduced.
The document has clear progressive sections for installation, environment variables, authentication, workflows, errors, configuration, best practices, types, and references; it also declares MIT licensing, author, and version. It lacks a changelog, explicit maintenance/update path, FAQ or systematic troubleshooting, and some examples depend on unstated surrounding context, so points are deducted.
The skill provides directly adaptable examples for connections, pools, parameterized queries, transactions, typing, and token refresh, with clear core-task value. Placeholder values and assumed users/orders schemas remain, the token-refresh pool example has usability risks, and no key-path execution evidence is supplied; light review and correction are still required.
The skill includes concrete code, configuration values, and reference links, while the repository provides general CI and test materials. The supplied tests do not cover this skill's key paths, and no committed skill-specific acceptance tests or third-party execution evidence are shown, so the assessment relies mainly on static text.
- The token-refresh pool example may race under concurrent requests or while connections are checked out, and its imports are incomplete; compile, concurrency, and token-expiry tests should be added before adoption.
- Do not log passwords or tokens; the interpolated connection-string example does not explain escaping special characters or secret management.
- Write examples execute INSERT operations without defining user confirmation, idempotency, least-privilege database roles, or business recovery after failure.
What it does & when to use it
This skill helps Node.js and TypeScript developers connect to Azure Database for PostgreSQL Flexible Server with pg (node-postgres). It covers password authentication and Microsoft Entra ID passwordless authentication, plus Client and Pool usage, parameterized queries, transactions, and typed results. It also documents token refresh for long-running applications, PostgreSQL error handling, connection strings, pool events, and Azure-specific settings. It is a focused fit for Azure PostgreSQL applications rather than a general database or ORM guide.
Shows how to install pg, @azure/identity, and @types/pg; read Azure PostgreSQL connection and authentication environment variables; create SSL-enabled Client or Pool connections; run parameterized SQL, transactions, and typed queries; obtain PostgreSQL access tokens with DefaultAzureCredential or managed identity; recreate pools before Entra ID token expiry; handle common PostgreSQL error codes; and configure pool sizing, timeouts, lifecycle events, and graceful shutdown.
- A Node.js/TypeScript developer needs a basic SSL-enabled connection to Azure PostgreSQL from environment variables.
- A production service needs pooling, connection timeouts, pool monitoring, and clean shutdown behavior.
- A backend performs related user and order writes that must be protected by transactions and parameterized queries.
- A team is moving from database passwords to Microsoft Entra ID or managed identity authentication.
- A long-running service needs to refresh Entra ID credentials without leaving an expired-password pool in use.
Pros & cons
- Covers both password and Microsoft Entra ID authentication.
- Includes production-oriented pooling, transactions, parameterized queries, and shutdown patterns.
- Provides TypeScript generics for query results and examples for common PostgreSQL error codes.
- Documents Azure-specific SSL, token scope, ports, token lifetime, and pool settings.
- Its scope is limited to Azure Database for PostgreSQL Flexible Server, Node.js/TypeScript, and pg.
- It does not cover migrations, schema design, ORMs, or application data modeling.
- The source does not identify a skill-specific test suite or runtime compatibility matrix.
- Pool sizing and token-refresh behavior still require adjustment for the application lifecycle, concurrency, and Azure SKU.
How to install
Install the collection with npx skills add microsoft/skills, then select azure-postgres-ts in the wizard. The README says selected skills are installed in the chosen agent directory, such as .github/skills/ for GitHub Copilot. The source does not define a separate package or standalone installation command for this skill.
How to use
In an Agent Skills-compatible coding agent, make a request such as: “Connect my TypeScript service to Azure PostgreSQL with pg, use a production connection pool, and authenticate with Microsoft Entra ID.” The skill supplies patterns for dependencies, environment variables, Client/Pool setup, transactions, parameterized queries, typed results, error handling, and token refresh. It does not prescribe a schema, deployment model, or application framework.
Compared to similar skills
The skill presents password authentication and Microsoft Entra ID passwordless authentication as the main authentication choices. Passwords are configured directly, while Entra ID uses DefaultAzureCredential or managed identity and passes an access token as the PostgreSQL password. For connection management, it contrasts a single Client with Pool and recommends Pool for production.