Azure PostgreSQL for TypeScript (node-postgres)
Connect TypeScript Apps to Azure PostgreSQL with Enterprise Security
Building production applications requires secure, scalable database connections. This skill provides complete patterns for Azure PostgreSQL with connection pooling, transactions, and passwordless Microsoft Entra ID authentication.
Download the skill ZIP
Upload in Claude
Go to Settings → Capabilities → Skills → Upload skill
Toggle on and start using
Test it
Using "Azure PostgreSQL for TypeScript (node-postgres)". User asks for a basic PostgreSQL connection setup
Expected outcome:
Provides a complete TypeScript code example showing Client initialization with environment variables, SSL configuration, connection establishment, query execution, and proper connection cleanup in a try/finally block.
Using "Azure PostgreSQL for TypeScript (node-postgres)". User needs connection pooling for production
Expected outcome:
Delivers a Pool configuration with production settings including max 20 connections, 30 second idle timeout, examples of query execution, explicit client checkout for multiple queries, and proper release patterns.
Using "Azure PostgreSQL for TypeScript (node-postgres)". User wants passwordless Entra ID authentication
Expected outcome:
Shows DefaultAzureCredential setup, token acquisition for PostgreSQL resource, using the token as password in client configuration, and a wrapper class for automatic token refresh before expiry.
Security Audit
SafeThis is a prompt-only skill containing documentation and code examples for Azure PostgreSQL connections. Static analysis scanned 0 files with 0 code lines since the skill only contains a SKILL.md documentation file. No executable code patterns, external commands, network calls, or dangerous operations were detected. The skill provides educational content about secure database connection practices including parameterized queries, SSL configuration, and proper credential handling.
Risk Factors
🔑 Env variables (1)
Quality Score
What You Can Build
Production API Backend
Build scalable backend services with connection pooling that efficiently handles concurrent database requests and automatic connection management.
Enterprise Secure Applications
Implement passwordless database authentication using Microsoft Entra ID managed identities for enhanced security compliance.
Data-Intensive Applications
Execute complex multi-statement operations with transaction support ensuring data consistency and integrity.
Try These Prompts
Show me how to connect to Azure PostgreSQL from TypeScript using the pg client with password authentication and SSL enabled.
Create a connection pool for Azure PostgreSQL with proper configuration for production use including max connections, idle timeout, and connection timeout settings.
Show me how to implement passwordless authentication to Azure PostgreSQL using Microsoft Entra ID managed identity with automatic token refresh.
Create a transaction helper function that wraps database operations with BEGIN, COMMIT, and ROLLBACK logic including proper error handling and connection release.
Best Practices
- Always use parameterized queries instead of string concatenation to prevent SQL injection vulnerabilities
- Use connection pools instead of single connections for production applications to improve performance and resource utilization
- Enable SSL with rejectUnauthorized set to true for all Azure PostgreSQL connections to ensure encrypted communication
Avoid
- Never concatenate user input directly into SQL queries - always use parameterized queries with placeholders
- Avoid creating new Client instances for every query - this exhausts database connections and degrades performance
- Do not skip token refresh logic when using Entra ID authentication - tokens expire after approximately one hour