AzureAzure Database for PostgreSQLDatabase

azurerm_postgresql_flexible_server_database cost estimation

A logical database inside a PostgreSQL Flexible Server. The database is free. Cost lives on the parent server: compute vCores, provisioned storage, IOPS, and backup beyond the free allowance.

The azurerm_postgresql_flexible_server_database resource creates a named logical database inside an already-running PostgreSQL Flexible Server. It is the equivalent of a CREATE DATABASE statement. Adding databases to a server costs nothing, because the server bills for compute and storage as a whole, not per database. All of your databases share the same vCores, memory, and provisioned disk.

The parent azurerm_postgresql_flexible_server is where the money is. Compute is billed per tier and size: a Burstable B1ms (1 vCore, 2 GB) runs roughly $12 to $13/month, a General Purpose D2s_v3 (2 vCore, 8 GB) is roughly $125/month, and a D4s_v3 (4 vCore, 16 GB) roughly $250/month, all before storage. Storage is provisioned, not consumption-based, at about $0.115/GB-month, and on some SKUs you pay separately for provisioned IOPS above the included baseline. Because storage is provisioned, you pay for the disk you allocate even if the databases on it are nearly empty.

Backup is the line that catches people. Automated backups are free up to 100% of your provisioned storage size, then billed at about $0.095/GB-month for extra, and geo-redundant backup roughly doubles that. A server with a long backup-retention window and high write churn can accumulate backup storage well beyond the free allowance.

The cost-adjacent gotcha is that stacking databases onto one server is usually the right move, but it also concentrates risk on a single compute size. If several databases share a Burstable server and one gets busy, they all slow down together, tempting an oversized upgrade. Size the server for the combined steady-state load and use Burstable only where bursts are genuinely intermittent. Also remember that a stopped Flexible Server still bills for its provisioned storage and backups even though compute is paused.

c3x flags azurerm_postgresql_flexible_server_database as free and attributes compute, storage, IOPS, and backup cost to the parent Flexible Server.

Terraform example

A minimal but realistic configuration that C3X can estimate.

resource "azurerm_postgresql_flexible_server" "main" {
  name                   = "app-pg"
  resource_group_name    = azurerm_resource_group.main.name
  location               = "eastus"
  version                = "16"
  administrator_login    = "pgadmin"
  administrator_password = var.pg_admin_password

  sku_name   = "GP_Standard_D2s_v3"
  storage_mb = 32768

  backup_retention_days        = 7
  geo_redundant_backup_enabled = false
}

resource "azurerm_postgresql_flexible_server_database" "app" {
  name      = "appdb"
  server_id = azurerm_postgresql_flexible_server.main.id
  charset   = "UTF8"
  collation = "en_US.utf8"
}

Pricing dimensions

What you actually pay for when you provision azurerm_postgresql_flexible_server_database.

DimensionUnitWhat's being charged
Logical databasefreeCreating a database inside the server carries no per-resource charge. Databases share the server's compute and storage.
$0 (free)
Compute (Burstable B1ms)per monthSmallest Burstable server, 1 vCore and 2 GB, before storage. Good for dev and light workloads.
about $12 to $13/month
Compute (General Purpose D2s_v3)per monthGeneral Purpose 2 vCore, 8 GB, before storage. Common production baseline.
about $125/month
Provisioned storageper GB-monthAllocated disk, billed whether or not the databases fill it. IOPS above baseline may bill separately.
about $0.115/GB-month
Backup storage (beyond free)per GB-monthAutomated backup storage past 100% of provisioned size. Geo-redundant backup roughly doubles the rate.
about $0.095/GB-month

Optimization tips

Common ways to reduce azurerm_postgresql_flexible_server_database cost without changing the workload.

Consolidate databases onto one right-sized server

$12+/month per avoided server

Databases are free and share the server's compute and storage. Put related databases on one server sized for their combined steady-state load rather than running a separate server per database.

Provision storage close to what you need

Storage is provisioned, not consumption-based, so an oversized disk bills at $0.115/GB-month for space you never use. Grow storage as data grows rather than allocating far ahead.

Keep backup retention and redundancy in check

About 50% of backup overage with LRS

Backups are free only up to your provisioned storage size. Long retention plus high write churn pushes you into paid backup storage, and geo-redundant backup doubles it. Set retention to your real recovery requirement.

Use Burstable only for genuinely intermittent load

Burstable servers are cheap but throttle to a baseline once credits run out. If several shared databases keep the server busy, move to General Purpose rather than paying for oversized Burstable bursts.

FAQ

Does each PostgreSQL database add to the bill?

No. Databases are free logical containers inside the server. Compute and storage are billed at the server level and shared across every database on it, so adding databases does not increase cost by itself.

What is the cheapest PostgreSQL Flexible Server?

A Burstable B1ms with 1 vCore and 2 GB runs about $12 to $13/month before storage, which is roughly $0.115/GB-month. It suits development and light workloads that only burst occasionally.

Why am I billed when my server is stopped?

Stopping a Flexible Server pauses compute billing, but you still pay for the provisioned storage and any backup storage. The stored data does not go away, so its storage cost continues.

How does backup storage get charged?

Automated backups are free up to 100% of your provisioned storage size. Beyond that it is about $0.095/GB-month, and enabling geo-redundant backup roughly doubles the rate. Long retention windows on write-heavy databases are the usual cause of overage.

Related resources

Estimate this resource in your own Terraform

Free, open source, no API key. C3X parses your Terraform and shows line-item cost for every resource, including azurerm_postgresql_flexible_server_database.