az sql db create: Create an Azure SQL Database
az sql db create provisions a database on an existing Azure SQL logical server.
Test databases for integration runs come from sql db create. The server must already exist, and a firewall rule is what usually blocks the first connection.
What it does
az sql db create provisions a database on a named Azure SQL server in a resource group, with a service tier set by --edition and compute by --service-objective. The logical server (az sql server create) must exist first.
Common usage
az sql db create \
--resource-group rg-app --server sql-ci \
--name appdb \
--edition GeneralPurpose \
--compute-model Serverless \
--family Gen5 --capacity 2Subcommands and flags
| Flag | What it does |
|---|---|
| --server, -s | Azure SQL logical server name |
| --name, -n | Database name |
| --edition, -e | Service tier, e.g. GeneralPurpose |
| --service-objective | Performance level, e.g. S0, GP_Gen5_2 |
| --compute-model | Provisioned or Serverless |
In CI
Create a firewall rule (az sql server firewall-rule create) for the runner outbound IP before connecting, or use a private endpoint. Prefer AAD auth over a SQL admin password so no static credential lives in the pipeline. Serverless tiers auto-pause, cutting cost between test runs.
Common errors in CI
"Cannot open server 'sql-ci' requested by the login. Client with IP address ... is not allowed to access the server" means no firewall rule covers the runner IP. "ResourceNotFound" on --server means the logical server does not exist. An invalid --service-objective for the chosen --edition is rejected with an unsupported combination error.