| reviewed | 2025-10-26 |
|---|---|
| severity | Awareness |
| pillar | Operational Excellence |
| category | OE:04 Continuous integration |
| resource | SQL Database |
| resourceType | Microsoft.Sql/servers/databases |
| online version | https://azure.github.io/PSRule.Rules.Azure/en/rules/Azure.SQL.DBName/ |
Azure SQL Database names should meet naming requirements.
When naming Azure resources, resource names must meet service requirements. The requirements for SQL Database names are:
- Between 1 and 128 characters long.
- Letters, numbers, and special characters except:
<>*%&:\/? - Can't end with period or a space.
- Must be unique for each logical server.
The following reserved database names can not be used:
mastermodeltempdb
Consider using names that meet Azure SQL Database naming requirements. Additionally consider naming resources with a standard naming convention.
To deploy databases that pass this rule:
- Set the
nameproperty to a string that matches the naming requirements. - Optionally, consider constraining name parameters with
minLengthandmaxLengthattributes.
For example:
@minLength(1)
@maxLength(128)
@description('The name of the resource.')
param name string
@description('The location resources will be deployed.')
param location string = resourceGroup().location
resource database 'Microsoft.Sql/servers/databases@2024-05-01-preview' = {
parent: server
name: name
location: location
properties: {
collation: 'SQL_Latin1_General_CP1_CI_AS'
maxSizeBytes: maxSize
catalogCollation: 'SQL_Latin1_General_CP1_CI_AS'
readScale: 'Disabled'
zoneRedundant: true
}
}To deploy databases that pass this rule:
- Set the
nameproperty to a string that matches the naming requirements. - Optionally, consider constraining name parameters with
minLengthandmaxLengthattributes.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"type": "string",
"minLength": 1,
"maxLength": 128,
"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/databases",
"apiVersion": "2024-05-01-preview",
"name": "[format('{0}/{1}', parameters('name'), parameters('name'))]",
"location": "[parameters('location')]",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"maxSizeBytes": "[variables('maxSize')]",
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"readScale": "Disabled",
"zoneRedundant": true
}
}
]
}This rule does not check if Azure SQL Database names are unique.