Saturday, 22 July 2023

Mapping SQL Database SKU Bicep Specs with Available SKUs in a Region

 How to fnd SKU information for SQL databses is documented here. The command suggested to use is az sql db list-editions -l region -o table . This would provide available list of SQL database SKU optons to chose form for a given region. However, the headings and parameters required in bicep is bit confusing to figure out intially. Let's look at how to map values for available SKUs provided by az sql db list-editions -l region -o table  command, and parmeters in Bicep SKU for SQL database.

Consider the Bicep code below for creating a SQL database.

param sqlserverName string
param sqldatabaseName string
param sqldatabaseSKUCapacity int
param sqldatabaseSKUFamily string
param sqldatabaseSKUName string
param sqldatabaseSKUSize string
param sqldatabaseSKUTier string
param sqldatabaseBackupStorageRedudancy string
param sqldatabaseMaxSizeBytes int
param location string

resource sqlServerDatabase 'Microsoft.Sql/servers/databases@2022-11-01-preview' = {
  name: '${sqlserverName}/${sqldatabaseName}'
  location: location

  sku: {
    capacity: sqldatabaseSKUCapacity
    family: sqldatabaseSKUFamily
    name: sqldatabaseSKUName
    size: sqldatabaseSKUSize
    tier: sqldatabaseSKUTier
  }

  properties: {
    requestedBackupStorageRedundancy:sqldatabaseBackupStorageRedudancy
    collation: 'SQL_Latin1_General_CP1_CI_AS'
    maxSizeBytes: sqldatabaseMaxSizeBytes
  }
}

The paramters can be mapped as shown in below. The example uses eastus region SKUs.


The mapping can be summaruzed below. 


  sku: {
    capacity: sqldatabaseSKUCapacity // Maps to Capacity
    family: sqldatabaseSKUFamily // Maps to Family
    name: sqldatabaseSKUName // Maps to sku
    size: sqldatabaseSKUSize // Maps to ServiceObjective
    tier: sqldatabaseSKUTier // Maps to Edition
  }

For standard DTU 50 it would be below in after deployed in ARM.


So full bicep parameters for SKU and size would be as below (This is from Azure DevOps variable group).



For general purpose example below


Settings goes as below in ARM template.

Parameters for bicep in Azure DevOps variable group as below.



No comments:

Popular Posts