azurerm_ postgresql_ flexible_ server cost estimation
A managed PostgreSQL server. Priced by compute SKU, storage size, and high-availability mode.
An azurerm_
First, compute. The server's SKU determines per-hour cost. Three tiers: Burstable (B-series, cheap, for low-baseline workloads), General Purpose (Dsv3-series, balanced), and Memory Optimized (Esv3-series, more RAM per vCPU). Within each tier, you pick a size. A B2s costs ~$0.034/hour ($25/month); a D4s_
Second, storage. Provisioned size from 32 GB to 16 TB, billed at $0.115/GB-month for general-purpose SSD. IOPS scale automatically with size (or with the iops_
Third, high availability. Three options: None (single server, default), SameZone (same-zone replica for ~2x compute cost), ZoneRedundant (cross-zone replica for ~2x compute cost). Replicas add the same hourly compute price as the primary, effectively doubling the bill.
Backup storage is free up to 100% of provisioned storage, then billed per GB-month. Point-in-time restore is available with backup retention up to 35 days.
c3x reads sku_
Terraform example
A minimal but realistic configuration that C3X can estimate.
resource "azurerm_postgresql_flexible_server" "main" {
name = "production-postgres"
resource_group_name = azurerm_resource_group.main.name
location = "eastus"
version = "16"
sku_name = "GP_Standard_D2s_v3"
storage_mb = 131072
storage_tier = "P10"
backup_retention_days = 14
geo_redundant_backup_enabled = false
administrator_login = "psqladmin"
administrator_password = var.db_password
high_availability {
mode = "ZoneRedundant"
}
}Pricing dimensions
What you actually pay for when you provision azurerm_.
| Dimension | Unit | What's being charged |
|---|---|---|
| Compute hours | per hour | Rate for the server SKU. Multiplied for HA replicas (doubles cost). $0.27/hour for GP_Standard_D2s_v3 in eastus |
| Storage | per GB-month | Provisioned storage. Cannot be reduced after creation. P-tier (Premium SSD) and PV2-tier (Premium SSD v2) have different per-GB rates. $0.115/GB-month general-purpose |
| Backup storage (above 100% of provisioned) | per GB-month | Backups up to provisioned size are free. Anything above is billed. Geo-redundant backups bill at higher rate. |
| High availability replica | multiplier | ZoneRedundant or SameZone HA provisions a hot standby. Effectively doubles compute cost. |
Optimization tips
Common ways to reduce azurerm_ cost without changing the workload.
Use Burstable (B-series) for non-production
Up to 80%B-series uses a credit-based CPU model and costs 70-80% less than General Purpose at the same advertised vCPU count. Right for dev, staging, and any workload with low average CPU.
Skip HA for non-production environments
About 50% on computeZone-Redundant HA doubles compute cost. Non-production typically doesn't need 99.99% SLA. Disabling HA for dev/staging cuts compute spend in half.
Buy reserved capacity for steady-state
30-60%Azure Reserved Capacity for PostgreSQL cuts compute prices by 30-60% with a 1- or 3-year commitment. Right for production databases that won't move.
Use Postgres connection pooling (PgBouncer)
Workload-dependentFlexible Server has built-in PgBouncer support. Enabling it lets a smaller SKU handle more clients than running connections directly to Postgres. Sometimes lets you downsize compute.
FAQ
Should I use Flexible Server or Single Server?
Flexible Server. Single Server is deprecated and being retired. Flexible Server has better pricing, more features (HA, read replicas, server parameter tuning), and is the active product line.
How does c3x handle read replicas?
Read replicas (azurerm_
Are backups really free?
Up to 100% of provisioned storage. A 1 TB server gets 1 TB of free backup. Beyond that, you pay per GB-month. Geo-redundant backup (geo_
What about Premium SSD v2 storage?
PSSDv2 is a newer storage tier with separate IOPS and throughput provisioning. Cheaper per GB but you pay extra for IOPS and MB/s. Right for high-performance workloads. c3x picks up the storage_
Related resources
More Azure resources
Further reading
- Azure PostgreSQL Flexible Server cost: tiers, HA, and reservations
Flexible Server bills compute by tier (Burstable ~$12/mo, General Purpose, Memory Optimized) + storage. HA doubles compute. Here's how to pick the tier, when to skip HA, and how reservations and stop/start cut the bill.
- How to estimate Azure costs from Terraform
Estimate Azure costs from Terraform configurations including Reserved Instances, Azure Hybrid Benefit, Spot VMs, and Premium SSD tier mapping. Completes the cloud trilogy alongside AWS and GCP.
- Managed PostgreSQL cost compared: RDS vs Cloud SQL vs Azure Flexible Server
AWS RDS, GCP Cloud SQL, and Azure Database for PostgreSQL Flexible Server price managed Postgres similarly, compute per vCPU and memory, storage, and high-availability options. The cost drivers and levers are shared. This compares them.
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_.