azurerm_mssql_database cost estimation
Managed SQL Server in Azure. DTU model from $4.90/month (Basic 5 DTU) or vCore model from $0.18/vCore-hour (General Purpose Serverless). Hyperscale tier scales beyond 4 TB. License-included or BYOL via Hybrid Benefit.
Azure SQL Database is the managed SQL Server offering. The azurerm_mssql_database has two main pricing models: DTU and vCore.
DTU (Database Transaction Unit) model bundles compute + storage + IO into a single unit. Tiers: - Basic (5 DTU): $4.90/month, 2 GB max - Standard (S0-S12): $0.02-$2.36/hour, 250 GB max - Premium (P1-P15): $0.61-$24.40/hour, 4 TB max
DTU is simpler but harder to right-size. Most new deployments use vCore.
vCore model (Recommended) prices compute and storage separately. Sub-tiers: - General Purpose: $0.21/vCore-hour (Gen5), $5/month/GB storage - Business Critical: $0.55/vCore-hour, $0.30/GB-month storage (premium SSD, in-memory OLTP) - Hyperscale: $0.21/vCore-hour, $0.115/GB-month, scales beyond 4 TB
Serverless tier auto-pauses when idle. Bills $0.5218/vCore-hour active, near-zero when paused. Great for dev/test or sporadic workloads.
Azure Hybrid Benefit lets BYOL on SQL Server licenses with Software Assurance, cutting up to 55% off vCore pricing. For Windows shops migrating from on-prem, this is a major lever.
c3x estimates SQL Database based on sku_name and license_type, with Hybrid Benefit detection via the license_type=BasePrice setting.
Terraform example
A minimal but realistic configuration that C3X can estimate.
resource "azurerm_mssql_server" "main" {
name = "prod-sql-server"
resource_group_name = azurerm_resource_group.main.name
location = azurerm_resource_group.main.location
version = "12.0"
administrator_login = "sqladmin"
administrator_login_password = var.sql_password
}
resource "azurerm_mssql_database" "app" {
name = "app-db"
server_id = azurerm_mssql_server.main.id
collation = "SQL_Latin1_General_CP1_CI_AS"
license_type = "LicenseIncluded"
max_size_gb = 50
sku_name = "GP_S_Gen5_2" # General Purpose Serverless, 2 vCore
zone_redundant = false
}Pricing dimensions
What you actually pay for when you provision azurerm_mssql_database.
| Dimension | Unit | What's being charged |
|---|---|---|
| vCore hours | per vCore-hour | Compute cost per vCore. Varies by tier (General Purpose, Business Critical, Hyperscale). $0.21/vCore-hour (GP), $0.55/vCore-hour (BC) |
| Storage | per GB-month | Database storage cost. Premium tiers use SSD with higher rates but better performance. $0.115/GB-month (GP), $0.30/GB-month (BC) |
| Backup storage | per GB-month | Backups beyond the included retention window (typically 7-35 days). Long-term retention bills separately. $0.024/GB-month (LRS), $0.05/GB-month (ZRS) |
| Hybrid Benefit license | license discount | BYOL on SQL Server with Software Assurance cuts up to 55% off vCore pricing. Saves ~40-55% on vCore cost |
Optimization tips
Common ways to reduce azurerm_mssql_database cost without changing the workload.
Apply Azure Hybrid Benefit
40-55% on vCore costIf your organization has SQL Server licenses with Software Assurance, set license_type='BasePrice' to apply Hybrid Benefit. Saves ~40% on vCore hours. Free if you already have the licenses.
Use Serverless for sporadic workloads
60-80% on idle workloadsGP_S_* SKUs auto-pause after inactivity. Dev databases used 8 hours/day weekdays cost ~25% of always-on. Audit which databases idle nights/weekends and migrate to serverless.
Right-size with auto-pause threshold
Variable based on idle patternServerless databases bill near-zero when paused. Tune auto_pause_delay_in_minutes (default 60 min). Lower values pause sooner but increase resume latency for next query.
Use Reserved Capacity for production
25-55% on commitment1-year reservations cut 25-30% vs pay-as-you-go. 3-year reservations cut 50-55%. Right after the workload baseline is stable.
Migrate to Hyperscale for large databases
60% on storage for 1TB+ DBsFor databases over 1 TB, Hyperscale is often cheaper than Business Critical and offers better scaling. Hyperscale storage is $0.115/GB-month vs BC's $0.30/GB-month — a 2.6x storage savings for large DBs.
FAQ
Should I use DTU or vCore?
Use vCore for new deployments. It's more flexible, has more SKU options, supports Reserved Capacity, and accommodates Azure Hybrid Benefit. DTU is legacy — kept for backwards compatibility. The conversion: 100 DTU ≈ 1 vCore for most workloads.
Is Serverless really cheaper for production?
For workloads with idle time (dev/test, internal tools, scheduled batch), yes. For 24/7 production with consistent load, the per-vCore-hour rate is higher than provisioned, so you'd pay more. Calculate: hours idle × pause-rate vs hours active × premium-rate.
Do I need to back up Azure SQL Database myself?
No. Automatic backups are included for 7-35 days (configurable). Long-Term Retention (up to 10 years) is available separately at backup storage rates. The free included backup is sufficient for most workloads.
What's the difference between Business Critical and Hyperscale?
Business Critical uses local SSD for fastest IO with in-memory OLTP support. Right for low-latency-sensitive OLTP. Hyperscale separates storage from compute, scales to 100+ TB, has faster backups/restores. Right for very large databases. BC is faster per-IO; Hyperscale scales further.
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_mssql_database.