Use valid container app names#
Operational Excellence · Container App · Rule · 2023_03 · Awareness
Container Apps should meet naming requirements.
Description#
When naming Azure resources, resource names must meet service requirements. The requirements for container app names are:
- Between 2 and 32 characters long.
- Lowercase letters, numbers, and hyphens.
- Start with letter and end with alphanumeric.
Recommendation#
Consider using container app names that meets naming requirements. Additionally consider naming resources with a standard naming convention.
Examples#
Configure with Azure template#
To deploy Container Apps that pass this rule:
- Configuring a
minLength
andmaxLength
constraint for the resource name parameter. - Optionally, you could also use a
uniqueString()
function to generate a unique name.
For example:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"envName": {
"type": "string",
"metadata": {
"description": "The name of the app environment."
}
},
"appName": {
"type": "string",
"minLength": 2,
"maxLength": 32,
"metadata": {
"description": "The name of the container app."
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "The location resources will be deployed."
}
},
"workspaceId": {
"type": "string",
"metadata": {
"description": "The name of a Log Analytics workspace"
}
},
"subnetId": {
"type": "string",
"metadata": {
"description": "The resource ID of a VNET subnet."
}
},
"revision": {
"type": "string",
"metadata": {
"description": "The revision of the container app."
}
}
},
"variables": {
"containers": [
{
"name": "simple-hello-world-container",
"image": "mcr.microsoft.com/azuredocs/containerapps-helloworld:latest",
"resources": {
"cpu": "[json('0.25')]",
"memory": ".5Gi"
}
}
]
},
"resources": [
{
"type": "Microsoft.App/containerApps",
"apiVersion": "2023-05-01",
"name": "[parameters('appName')]",
"location": "[parameters('location')]",
"identity": {
"type": "SystemAssigned"
},
"properties": {
"environmentId": "[resourceId('Microsoft.App/managedEnvironments', parameters('envName'))]",
"template": {
"revisionSuffix": "[parameters('revision')]",
"containers": "[variables('containers')]",
"scale": {
"minReplicas": 2
}
},
"configuration": {
"ingress": {
"allowInsecure": false,
"stickySessions": {
"affinity": "none"
}
}
}
}
}
]
}
Configure with Bicep#
To deploy Container Apps that pass this rule:
- Configuring a
minLength
andmaxLength
constraint for the resource name parameter. - Optionally, you could also use a
uniqueString()
function to generate a unique name.
For example:
@minLength(2)
@maxLength(32)
@description('The name of the container app.')
param appName string
resource containerApp 'Microsoft.App/containerApps@2023-05-01' = {
name: appName
location: location
identity: {
type: 'SystemAssigned'
}
properties: {
environmentId: containerEnv.id
template: {
revisionSuffix: revision
containers: containers
scale: {
minReplicas: 2
}
}
configuration: {
ingress: {
allowInsecure: false
stickySessions: {
affinity: 'none'
}
}
}
}
}
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:
For example:
To use the latest version:
Notes#
This rule does not check if container app names are unique.
Links#
- OE:04 Continuous integration
- Naming rules and restrictions for container app resource
- Azure deployment reference