Lesson 1 of 5 Developing with Azure Database for PostgreSQL

Understanding Azure Database for PostgreSQL

This lesson explains flexible server compute and storage, networking and authentication, server parameters and the extension allow-list.

Learning outcomes

After completing this lesson, you will be able to:

  • Compare the Burstable, General Purpose and Memory Optimized tiers.
  • Distinguish public access from private access.
  • Explain Microsoft Entra authentication for PostgreSQL.
  • Describe how extensions are allow-listed and created.

A managed PostgreSQL

PostgreSQL is an open-source relational database known for standards compliance, a rich type system and extensibility. Azure Database for PostgreSQL flexible server runs community PostgreSQL as a managed service: Azure handles provisioning, patching, automated backups, high availability and monitoring, while the developer works with ordinary PostgreSQL databases, SQL and drivers. Flexible server is the current deployment option; the older single server option has been retired.

For AI solutions, PostgreSQL is attractive because the same database can hold relational business data, JSON documents in jsonb columns, full-text search indexes and, through the pgvector extension, embeddings with vector indexes. A retrieval query can then join chunks to their documents and filter on any SQL condition in one statement.

Compute and storage

A server's compute is chosen from three tiers, and the tier can be changed later with a short restart.

Burstable
CPU modelBaseline CPU with credits for bursts
Memory per vCoreLow
Typical useDevelopment, tests, low-traffic apps
Built-in PgBouncerNot supported
Choose when Cost matters more than sustained performance
General Purpose
CPU modelDedicated vCores
Memory per vCoreAbout 4 GiB
Typical useMost production workloads
Built-in PgBouncerSupported
Choose when Balanced production workloads
Memory Optimized
CPU modelDedicated vCores
Memory per vCoreAbout 8 GiB
Typical useLarge caches and in-memory indexes, such as big vector indexes
Built-in PgBouncerSupported
Choose when Working sets and indexes that must stay in memory

Storage is provisioned separately. With Premium SSD, IOPS and throughput rise with the provisioned size, and storage can grow automatically. Premium SSD v2 lets IOPS and throughput be set independently of size, which helps I/O-heavy workloads that do not need much capacity. Backups are automatic, with a retention of 7 to 35 days and point-in-time restore. Zone-redundant high availability keeps a standby in another availability zone, and read replicas serve read traffic from copies of the server.

The following diagram compares PostgreSQL flexible server configurations for each stage of a project.

Azure Database for PostgreSQL flexible server configurations for each stage. The prototype fits a cheap Burstable server. Production needs Memory Optimized compute with enough memory to keep the 40 GB HNSW index cached and the built-in PgBouncer for the scaled-out API, which Burstable does not support. Both stages use Microsoft Entra authentication with passwords disabled and allow-list vector in azure.extensions.
General Purpose may be adequate only if its memory holds the index.
Sort into groups

Which compute tier?

Exam skills 2.2.4

Choose the flexible server compute tier for each situation.

Log in to try this activity Interactive activities are free with an account.

Networking and authentication

A server is created with one of two networking models. Public access gives it a public endpoint protected by firewall rules that list allowed IP addresses or ranges; a special rule allows access from all Azure services. Public-access servers can also have private endpoints. Private access places the server inside a delegated subnet of a virtual network, with no public endpoint at all. Production AI back ends normally use private connectivity, with the application in the same virtual network or a peered one.

Authentication can use PostgreSQL authentication (user names and passwords stored in the database), Microsoft Entra authentication, or both. With Entra authentication, a Microsoft Entra administrator is set on the server, and Entra users, groups and managed identities are mapped to database roles. Applications then connect with an access token instead of a password, so no database password is stored anywhere. Password authentication can be disabled entirely.

az postgres flexible-server create --resource-group RG --name SERVER --location LOCATION \
  --tier GeneralPurpose --sku-name Standard_D2ds_v5 --storage-size 64 --version 16 \
  --microsoft-entra-auth Enabled --password-auth Disabled \
  --admin-object-id OBJECT_ID --admin-display-name ADMIN_UPN --admin-type User

This command creates a General Purpose server with 64 GiB of storage and Entra-only authentication, with the given user as the Entra administrator. Connections always use TLS.

Scenario questions

Network and sign-in

Exam skills 2.2.1

Choose the networking or authentication option that fits each requirement.

Log in to try this activity Interactive activities are free with an account.

Server parameters and extensions

Most PostgreSQL configuration is exposed as server parameters, changed with az postgres flexible-server parameter set or in the portal. Some are dynamic and take effect at once; others, marked static, require a restart. Parameters that matter for AI workloads include max_connections, shared_buffers, work_mem, maintenance_work_mem (memory for index builds) and max_parallel_workers_per_gather.

Extensions add types, functions and index methods to PostgreSQL. On flexible server, an extension must first be allow-listed in the azure.extensions server parameter; only then can a user with sufficient rights run CREATE EXTENSION in a database. A few extensions also need to be added to shared_preload_libraries, which requires a restart. The pgvector extension is named vector in both places.

az postgres flexible-server parameter set --resource-group RG --server-name SERVER \
  --name azure.extensions --value vector,pg_diskann
psql "host=SERVER.postgres.database.azure.com dbname=postgres user=ADMIN_UPN sslmode=require" \
  -c "CREATE EXTENSION IF NOT EXISTS vector;"

Allow-list first

Running CREATE EXTENSION vector on a new server fails with an error that the extension is not allow-listed. The fix is the azure.extensions server parameter, not a support request or a different tier.

Match the pairs

Server parameters

Exam skills 2.2.4

Match each server parameter with what it controls.

Log in to try this activity Interactive activities are free with an account.
Worked example

Choosing a server for a RAG prototype and production

A team prototypes a RAG service with 50,000 chunks and few users, then plans production with 20 million chunks, an HNSW index of about 40 GB, steady query traffic from a scaled-out API and a security rule that forbids database passwords. Which configurations fit each stage?

The prototype fits a Burstable server: cheap, with enough performance for occasional queries. Production needs Memory Optimized compute with enough memory to keep the 40 GB index cached, because an index that spills to disk makes each search slow. The scaled-out API benefits from the built-in PgBouncer, which Burstable does not support. Both stages should use Microsoft Entra authentication with password authentication disabled, and allow-list vector in azure.extensions.

Keeping production on Burstable would exhaust CPU credits under steady load. General Purpose may be adequate only if its memory holds the index. A password stored in Key Vault would still be a password, which the rule forbids.

Check yourself

CREATE EXTENSION vector fails on a new flexible server with an allow-list error. What must be done first?

Show answer

Add vector to the azure.extensions server parameter, which allow-lists the extension; then run CREATE EXTENSION in the database.

Exam Tips

Remember for the exam

  • Burstable for development; General Purpose for most production; Memory Optimized for large in-memory indexes.
  • Allow-list extensions in azure.extensions before CREATE EXTENSION.
  • Microsoft Entra authentication replaces database passwords with access tokens.
  • Built-in PgBouncer is not supported on the Burstable tier.