Use valid Cosmos DB account names
November 27, 2025 ยท View on GitHub
SYNOPSIS
Cosmos DB account names should meet naming requirements.
DESCRIPTION
When naming Azure resources, resource names must meet service requirements. The requirements for Cosmos DB account names are:
- Between 3 and 44 characters long.
- Lowercase letters, numbers, and hyphens.
- Start and end with letters and numbers.
- Cosmos DB account names must be globally unique.
RECOMMENDATION
Consider using names that meet Cosmos DB account naming requirements. Additionally consider naming resources with a standard naming convention.
EXAMPLES
Configure with Bicep
To deploy accounts 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(3)
@maxLength(44)
@description('The name of the resource.')
param name string
@description('The location resources will be deployed.')
param location string = resourceGroup().location
resource account 'Microsoft.DocumentDB/databaseAccounts@2025-04-15' = {
name: name
location: location
properties: {
enableFreeTier: false
consistencyPolicy: {
defaultConsistencyLevel: 'Session'
}
databaseAccountOfferType: 'Standard'
locations: [
{
locationName: location
failoverPriority: 0
isZoneRedundant: true
}
]
disableKeyBasedMetadataWriteAccess: true
minimalTlsVersion: 'Tls12'
}
}
Configure with Azure template
To deploy accounts that pass this rule:
- Set the
nameproperty to a string that matches the naming requirements. - Optionally, consider constraining name parameters with
minLengthandmaxLengthattributes.
For example:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"type": "string",
"minLength": 3,
"maxLength": 44,
"metadata": {
"description": "The name of the resource."
}
}
},
"resources": [
{
"type": "Microsoft.DocumentDB/databaseAccounts",
"apiVersion": "2025-04-15",
"name": "[parameters('name')]",
"location": "[parameters('location')]",
"properties": {
"enableFreeTier": false,
"consistencyPolicy": {
"defaultConsistencyLevel": "Session"
},
"databaseAccountOfferType": "Standard",
"locations": [
{
"locationName": "[parameters('location')]",
"failoverPriority": 0,
"isZoneRedundant": true
}
],
"disableKeyBasedMetadataWriteAccess": true,
"minimalTlsVersion": "Tls12"
}
}
]
}
NOTES
This rule does not check if Cosmos DB account names are unique.