Use valid Load Balancer names#
Operational Excellence · Load Balancer · Rule · 2020_06 · Awareness
Load Balancer names should meet naming requirements.
Description#
When naming Azure resources, resource names must meet service requirements. The requirements for Load Balancer names are:
- Between 1 and 80 characters long.
- Alphanumerics, underscores, periods, and hyphens.
- Start with alphanumeric.
- End alphanumeric or underscore.
- Load Balancer names must be unique within a resource group.
Recommendation#
Consider using names that meet Load Balancer naming requirements. Additionally consider naming resources with a standard naming convention.
Examples#
Configure with Bicep#
To deploy load balancers 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:
@minLength(1)
@maxLength(80)
@description('The name of the resource.')
param name string
@description('The location resources will be deployed.')
param location string = resourceGroup().location
resource internal_lb 'Microsoft.Network/loadBalancers@2024-05-01' = {
name: name
location: location
sku: {
name: 'Standard'
tier: 'Regional'
}
properties: {
frontendIPConfigurations: [
{
name: 'frontendIPConfig'
properties: {
privateIPAllocationMethod: 'Dynamic'
subnet: {
id: subnetId
}
}
zones: [
'1'
'2'
'3'
]
}
]
}
}
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 load balancers 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/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.34.44.8038",
"templateHash": "15799925094518670850"
}
},
"parameters": {
"name": {
"type": "string",
"minLength": 1,
"maxLength": 80,
"metadata": {
"description": "The name of the resource."
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "The location resources will be deployed."
}
},
"subnetId": {
"type": "string",
"metadata": {
"description": "The resource ID of the virtual network subnet."
}
},
"pipId": {
"type": "string",
"metadata": {
"description": "The resource ID of the public IP address."
}
}
},
"resources": [
{
"type": "Microsoft.Network/loadBalancers",
"apiVersion": "2024-05-01",
"name": "[parameters('name')]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard",
"tier": "Regional"
},
"properties": {
"frontendIPConfigurations": [
{
"name": "frontendIPConfig",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[parameters('subnetId')]"
}
},
"zones": [
"1",
"2",
"3"
]
}
]
}
}
]
}
Notes#
This rule does not check if Load Balancer 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