azurerm_mysql_flexible_server cost estimation
Managed MySQL with vCPU-based pricing. Burstable B1ms at $13.87/month, General Purpose D2ds_v4 at ~$140/month. Storage $0.115/GB-month. HA doubles compute cost; zone-redundant adds 25% on top.
Azure Database for MySQL Flexible Server is the recommended managed MySQL offering. The aws_mysql_flexible_server replaces the older Single Server offering (now legacy). Pricing combines compute (per vCPU/hour) and storage (per GB-month) with optional HA premiums.
Compute tiers: - Burstable (B-series): Cheapest, accumulates CPU credits during idle. B1ms (1 vCore, 2 GB): $13.87/month. Right for dev/test. - General Purpose (Ddsv4): Production default. D2ds_v4 (2 vCore, 8 GB): ~$140/month. - Memory Optimized (Edsv4): For memory-bound workloads. E2ds_v4 (2 vCore, 16 GB): ~$200/month.
Storage: $0.115/GB-month for the data volume. Storage scales independently from compute, 20 GB to 16 TB.
High Availability options: - Zone-redundant HA: Replica in another AZ, automatic failover. ~25% premium over base compute. - Same-zone HA: Replica in same AZ, faster failover. ~15% premium. - No HA: Single instance, no failover. Cheapest.
Backup storage included up to the configured retention period (7-35 days). Beyond that, $0.20/GB-month (cool tier).
Reserved Capacity reduces compute cost 30-65% (1-year/3-year commits). Available on General Purpose and Memory Optimized tiers, not Burstable.
c3x estimates MySQL Flexible Server based on sku_name, storage_mb, high_availability mode, and backup_retention_days.
Terraform example
A minimal but realistic configuration that C3X can estimate.
resource "azurerm_mysql_flexible_server" "main" {
name = "prod-mysql"
resource_group_name = azurerm_resource_group.main.name
location = azurerm_resource_group.main.location
administrator_login = "mysqladmin"
administrator_password = var.mysql_password
version = "8.0.21"
sku_name = "GP_Standard_D2ds_v4"
storage {
size_gb = 100
iops = 360
auto_grow_enabled = true
}
backup_retention_days = 14
high_availability {
mode = "ZoneRedundant"
standby_availability_zone = "2"
}
}Pricing dimensions
What you actually pay for when you provision azurerm_mysql_flexible_server.
| Dimension | Unit | What's being charged |
|---|---|---|
| Compute (vCore hours) | per vCore-hour | Hourly compute cost based on the sku_name and number of vCores. $0.0193/vCore-hour (B1ms), $0.10/vCore-hour (D2ds_v4) |
| Storage | per GB-month | Database storage capacity. Scales independently of compute. $0.115/GB-month |
| High Availability premium | percentage | Additional cost for HA replica. Zone-redundant ~25%, same-zone ~15%. +15-25% on compute |
| Backup storage (above retention) | per GB-month | Backup storage beyond the retention period (7-35 days). Backups within retention are included. $0.20/GB-month (cool tier) |
Optimization tips
Common ways to reduce azurerm_mysql_flexible_server cost without changing the workload.
Use Burstable for development
50% vs General PurposeB1ms at $13.87/month is half the price of comparable General Purpose. Earns CPU credits during idle and bursts when needed. Right for dev/test, staging, internal tools that aren't constantly busy.
Skip HA on non-critical workloads
15-25% on computeHA adds 15-25% to compute cost. Required for production OLTP, but unnecessary for analytics replicas, dev databases, and tooling. Audit which databases actually need HA.
Use Reserved Capacity for production
30-65% on compute1-year reservation saves 30-40%. 3-year saves 55-65%. Apply after the workload size is stable. Reservations are size-flexible within a family (D2ds → D4ds → D8ds).
Tune backup retention
VariableDefault backup retention varies by region but is often 7 days. For non-critical workloads, set retention to 7 days. For compliance, use minimum required, not 35 days as default. Each day extends backup storage cost.
FAQ
What's the difference between Flexible Server and Single Server?
Single Server is the legacy offering, scheduled for retirement in 2024-2025. Flexible Server is the modern replacement with better price-performance, more control over maintenance windows, configurable HA, and Reserved Capacity support. Use Flexible Server for all new deployments.
Is Burstable suitable for production?
For low-traffic production workloads (internal tools, low-traffic SaaS, side projects), yes. Bursts up to 100% CPU during high load. For consistent production load, you'll exhaust credits and throttle to baseline (20-67% CPU depending on SKU). Monitor AvailableCredits to verify.
How does Reserved Capacity work with HA?
Reservations cover the primary node, not the HA replica. The replica continues to bill at on-demand. So for a 2-vCore zone-redundant HA database with 1-year reservation: 2 vCore reserved + 2 vCore replica on-demand. Effective discount is on half the compute.
Can I scale up/down without downtime?
Scaling compute (vCore) typically requires a brief restart (under 60 seconds). Scaling storage up is online. Tier changes (Burstable → General Purpose) require a restart. For zero-downtime, use read replicas and failover.
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_mysql_flexible_server.