Resource Group name must be valid#
Operational Excellence · Resource Group · Rule · 2020_06 · Awareness
Azure Resource Manager (ARM) has requirements for Resource Groups names.
Description#
When naming Azure resources, resource names must meet service requirements. The requirements for Resource Group names are:
- Between 1 and 90 characters long.
- Alphanumerics, underscores, parentheses, hyphens, periods.
- Can't end with period.
- Resource Group names must be unique within a subscription.
Recommendation#
Consider using names that meet Resource Group naming requirements. Additionally consider naming resources with a standard naming convention.
Examples#
Configure with Bicep#
To deploy resource groups that pass this rule:
- Set the
name
property to a string that matches the naming requirements. - Optionally, consider constraining name parameters with
minLength
andmaxLength
attributes.
For example:
targetScope = 'subscription'
@minLength(1)
@maxLength(90)
@description('The name of the resource group.')
param name string
@description('The location resource group will be deployed.')
param location string
resource rg 'Microsoft.Resources/resourceGroups@2024-11-01' = {
name: name
location: location
tags: {
environment: 'production'
costCode: '349921'
}
}
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:
To use the latest version:
Configure with Azure template#
To deploy resource groups that pass this rule:
- Set the
name
property to a string that matches the naming requirements. - Optionally, consider constraining name parameters with
minLength
andmaxLength
attributes.
For example:
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.34.44.8038",
"templateHash": "2313748121071500940"
}
},
"parameters": {
"name": {
"type": "string",
"minLength": 1,
"maxLength": 90,
"metadata": {
"description": "The name of the resource group."
}
},
"location": {
"type": "string",
"metadata": {
"description": "The location resource group will be deployed."
}
}
},
"resources": [
{
"type": "Microsoft.Resources/resourceGroups",
"apiVersion": "2024-11-01",
"name": "[parameters('name')]",
"location": "[parameters('location')]",
"tags": {
"environment": "production",
"costCode": "349921"
}
}
]
}
Notes#
This rule does not check if Resource Group names are unique.
Links#
- OE:04 Continuous integration
- Naming rules and restrictions for Azure resources
- Recommended abbreviations for Azure resource types
- Parameters in Bicep
- Bicep functions
- Azure deployment reference