Azure Database for PostgreSQL
Overview
Azure Database for PostgreSQL is a managed relational database service that provides built-in high availability, automated backups, scaling, security, and compliance. It offers two deployment options:
- Single Server: Fully managed single-instance database with automatic patches and backups.
- Flexible Server: More control over maintenance windows, high availability, and scaling.
Use PostgreSQL for modern applications, data warehousing, geospatial data, and more.
Quickstart: Create a PostgreSQL Flexible Server
- Open the Azure portal and click Create a resource.
- Search for
Azure Database for PostgreSQL flexible server. - Configure the basics:
- Subscription and Resource group
- Server name (unique globally)
- Region
- Version (e.g., PostgreSQL 15)
- Set authentication method: Password or Azure AD.
- Configure compute + storage as needed.
- Review + create.
Once deployed, connect using psql or any PostgreSQL client.
# Example using psql
psql "host=<servername>.postgres.database.azure.com port=5432 dbname=postgres user=<username>@<servername> password=<your_password> sslmode=require"
Code Sample: Node.js with pg
const { Pool } = require('pg');
const pool = new Pool({
user: 'myadmin@myserver',
host: 'myserver.postgres.database.azure.com',
database: 'mydb',
password: process.env.PG_PASSWORD,
port: 5432,
ssl: { rejectUnauthorized: false }
});
(async () => {
const client = await pool.connect();
const res = await client.query('SELECT NOW()');
console.log(res.rows[0]);
client.release();
})();
Monitoring & Performance
Azure provides built‑in metrics and logs via Azure Monitor. Enable Query Performance Insight to see top‑consuming queries.
- CPU usage
- Memory usage
- IO throughput
- Active connections
Security Features
- Data encryption at rest (Azure‑managed keys or Customer‑managed keys)
- SSL/TLS connections enforced
- VNet integration and private endpoints
- Azure AD authentication
- Built‑in firewall rules