Skip to content

SqlDatabase

The SqlDatabase resource creates a managed SQL database (PaaS) — on Azure, an Azure SQL database (New-AzSqlDatabase) — on a SqlServer resource of the same deployment.

Structure

- type: sqlDatabase
  name: appdb                           # unique identifier within the RGT
  displayName: App11 Database           # optional
  server: sqlsrv                        # references the parent sqlServer by name
  databaseName: App11_Main              # database name on the server
  tags:                                 # optional
    env: prod
  providerConfig:                       # optional, provider-specific settings
    azure:
      sku: GP_S_Gen5_2
      collation: SQL_Latin1_General_CP1_CI_AS
      maxSize: 100GB
      zoneRedundant: false
      backupStorageRedundancy: Zone
      readScale: false
      licenseType: LicenseIncluded
      autoPauseDelay: 60                # serverless only, minutes (-1 disables)
      minCapacity: 0.5                  # serverless only, min vCores
Key Required Description
type Yes Must be sqlDatabase
name Yes Unique identifier within the RGT (used in expressions)
displayName No Display name of the Dune resource
description No Description of the Dune resource
server Yes Parent SqlServer, referenced by its Dune name (or a template expression)
databaseName Yes Name of the database created on the server. Unlike the Dune resource name, it may contain underscores, dots and uppercase letters (e.g. App11_Main).
tags No Tags applied to the provider resource
providerConfig No Provider-specific settings, see below

providerConfig.azure

Key Required Default Description
sku No S0 (Standard) Service objective name as Azure expects it, e.g. S0, GP_S_Gen5_2, BC_Gen5_4. See SKU format.
collation No SQL_Latin1_General_CP1_CI_AS Database collation
maxSize No SKU-dependent (S0: 250 GB, GP_*: 32 GB) Maximum database size. A plain number is interpreted as GB; a string may carry a MB/GB/TB unit suffix (e.g. 500MB, 2GB, 1TB).
zoneRedundant No false Spread replicas across availability zones (Premium / Business Critical / General Purpose tiers)
backupStorageRedundancy No Geo Local, Zone, Geo or GeoZone
readScale No false (Premium / Business Critical: true) Boolean. Read scale-out — only effective on Premium / Business Critical / Hyperscale tiers.
licenseType No LicenseIncluded BasePrice applies Azure Hybrid Benefit (bring your own SQL Server license). Only effective on vCore-based tiers.
autoPauseDelay No 60 Serverless SKUs only. Minutes of inactivity before the database auto-pauses (minimum 60); -1 disables auto-pause.
minCapacity No SKU-dependent (GP_S_Gen5_2: 0.5) Serverless SKUs only. Minimum vCores the database always has allocated when not paused, e.g. 0.5.

SKU format

The sku (service objective) name encodes the compute configuration:

  • DTU-based tiers use plain names: Basic, S0–S12 (Standard), P1–P15 (Premium).
  • vCore-based tiers follow <Tier>_<HardwareGen>_<vCores>, e.g. GP_Gen5_4 = General Purpose, Gen5 hardware, 4 provisioned vCores. The trailing number is the (max) vCore count — there is no separate parameter for it.
  • Serverless inserts _S_: GP_S_Gen5_2 = General Purpose Serverless, Gen5, max 2 vCores. The minimum vCores and auto-pause behavior are not part of the SKU name — use minCapacity and autoPauseDelay for those.

Deployment Order

sqlServer and sqlDatabase resources are deployed in parallel. The database runbook resolves its server reference through the expression store, which is populated by the server deployment — the database automatically waits (up to 15 minutes) until the parent server is available. No dependsOn is required for the parent server.

Removal

Removing a sqlServer resource removes the server including all its databases on the provider. A sqlDatabase resource removed after its server skips the provider step gracefully and only deletes the Dune object.

Reference Format

Use {{sqldatabase.<name>.<property>}} to reference the database in expressions.

Expression Type Example output
{{sqldatabase.appdb}} string App11_Main (the database name)
{{sqldatabase.appdb.databasename}} string App11_Main
{{sqldatabase.appdb.servername}} string zh0042 (parent server short name)

A typical connection string in a config task combines server and database references:

postConfig:
  - name: invoke-psscript
    variables:
      script: |
        $ConnectionString = "Server=tcp:{{sqlserver.sqlsrv.fqdn}},1433;Initial Catalog={{sqldatabase.appdb}};User ID={{sqlserver.sqlsrv.administratorlogin}};Password=<from Vault>;"

Warning

The administrator password is only available in Vault (deployments/<DeploymentName>/sqlServer, key administrator_password) — it is not resolvable through expressions. See SqlServer — Administrator Credentials.

Example

Serverless General Purpose database with size cap on a private SQL server:

resources:
  - type: sqlServer
    name: sqlsrv
    serverName: zh0042
    administratorLogin: sqladmin
    privateLink: true
  - type: sqlDatabase
    name: appdb
    displayName: App11 Database
    server: sqlsrv
    databaseName: App11_Main
    providerConfig:
      azure:
        sku: GP_S_Gen5_2
        maxSize: 100GB
        backupStorageRedundancy: Zone
        autoPauseDelay: 120
        minCapacity: 0.5

Next: Action Template