Skip to content

Use valid SQL logical server names#

Operational Excellence · SQL Database · Rule · 2020_12 · Awareness

Azure SQL logical server names should meet naming requirements.

Description#

When naming Azure resources, resource names must meet service requirements. The requirements for SQL logical server names are:

  • Between 1 and 63 characters long.
  • Lowercase letters, numbers, and hyphens.
  • Can't start or end with a hyphen.
  • SQL logical server names must be globally unique.

Recommendation#

Consider using names that meet Azure SQL logical server naming requirements. Additionally consider naming resources with a standard naming convention.

Examples#

Configure with Bicep#

To deploy servers that pass this rule:

  • Set the name property to a string that matches the naming requirements.
  • Optionally, consider constraining name parameters with minLength and maxLength attributes.

For example:

Azure Bicep snippet
@minLength(1)
@maxLength(63)
@description('The name of the resource.')
param name string

@description('The location resources will be deployed.')
param location string = resourceGroup().location

resource server 'Microsoft.Sql/servers@2024-05-01-preview' = {
  name: name
  location: location
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
    publicNetworkAccess: 'Disabled'
    minimalTlsVersion: '1.3'
    administrators: {
      azureADOnlyAuthentication: true
      administratorType: 'ActiveDirectory'
      login: adminLogin
      principalType: 'Group'
      sid: adminPrincipalId
      tenantId: tenant().tenantId
    }
  }
}

Configure with Azure Verified Modules

A pre-validated module supported by Microsoft is available from the Azure Bicep public registry. To reference the module, please use the following syntax:

br/public:avm/res/sql/server:<version>

To use the latest version:

br/public:avm/res/sql/server:0.9.1

Configure with Azure template#

To deploy servers that pass this rule:

  • Set the name property to a string that matches the naming requirements.
  • Optionally, consider constraining name parameters with minLength and maxLength attributes.
Azure Template snippet
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 63,
      "metadata": {
        "description": "The name of the resource."
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "The location resources will be deployed."
      }
    }
  },
  "resources": [
    {
      "type": "Microsoft.Sql/servers",
      "apiVersion": "2024-05-01-preview",
      "name": "[parameters('name')]",
      "location": "[parameters('location')]",
      "identity": {
        "type": "SystemAssigned"
      },
      "properties": {
        "publicNetworkAccess": "Disabled",
        "minimalTlsVersion": "1.3",
        "administrators": {
          "azureADOnlyAuthentication": true,
          "administratorType": "ActiveDirectory",
          "login": "[parameters('adminLogin')]",
          "principalType": "Group",
          "sid": "[parameters('adminPrincipalId')]",
          "tenantId": "[tenant().tenantId]"
        }
      }
    }
  ]
}

Notes#

This rule does not check if Azure SQL logical server names are unique.

Comments