# Azure SQL Could Use Serverless Tier

> Flags provisioned General Purpose Azure SQL databases with low CPU and measured idle hours that serverless auto-pause would not bill.

Source: https://zop.dev/integrations/azure/recommendations/azure-sql-could-use-serverless-tier

---

## Provisioned compute billed through hours with no queries

A provisioned vCore database pays for its vCores every hour. The
[serverless tier overview](https://learn.microsoft.com/en-us/azure/azure-sql/database/serverless-tier-overview)
describes the alternative for single databases: compute scales with demand and is billed per
second, and after a configurable auto-pause delay of inactivity the database pauses. While paused
the compute cost is zero and only storage is billed. Microsoft notes auto-pause and auto-resume are
supported only in the General Purpose tier.

Development, reporting and internal-tool databases often go silent every night and weekend. On
provisioned compute those hours cost the same as a busy Monday morning.

## Finding General Purpose databases with low CPU

```bash
az sql db list --resource-group my-rg --server my-server \
  --query "[?starts_with(currentServiceObjectiveName, 'GP_')].{name:name, objective:currentServiceObjectiveName}" \
  -o table

az monitor metrics list --resource <database-resource-id> \
  --metric cpu_percent --aggregation Average Maximum --interval PT1H --offset 30d
```

Service objectives with `GP_S_` in the name are already serverless.

## What qualifies a database for serverless

1. The service objective is a General Purpose vCore one starting with `GP_`. DTU tiers (Basic,
   Standard, Premium) and system databases are excluded, and an unknown objective is not assumed.
2. The database is not already serverless and is not paused.
3. Either CPU percentage averages below 10% over 30 days, or, when no CPU data is available, the
   name marks it as dev, test, qa, staging, sandbox or demo.
4. ZopNight has measured idle hours for the database in its weekly activity heatmap, and the
   database has a monthly cost.

## Databases kept on provisioned compute

Business Critical and Hyperscale databases are outside scope, because auto-pause is a General
Purpose feature. Without measured idle time or cost data there is no recommendation; ZopNight does
not assume a flat share of the bill.

## Pausing compute, not storage

```text
monthly saving = database monthly cost x 0.70 x measured idle fraction
```

Storage keeps billing while a serverless database is paused, so only the compute part of the bill
can shrink. ZopNight treats 70% of the provisioned bill as compute, an assumed split rather than a
measured one, and applies the idle fraction to that share. The recommendation carries the heatmap
and a suggested schedule so you can see which hours drive the figure.

## Switching the database to serverless

1. Check that the application retries connections, since the first login after a pause waits for
   the database to resume.
2. Choose an auto-pause delay; Microsoft's minimum is 15 minutes.
3. Change the compute model:
   `az sql db update --resource-group my-rg --server my-server --name my-db --compute-model Serverless --auto-pause-delay 60`.
4. Watch the database's paused hours and billed vCore seconds over the next billing period.
