Skip to content

Use valid registry names#

Operational Excellence · Container Registry · Rule · 2020_06 · Awareness

Container registry names should meet naming requirements.

Description#

When naming Azure resources, resource names must meet service requirements. The requirements for container registry names are:

  • Between 5 and 50 characters long.
  • Alphanumerics.
  • Container registry names must be globally unique.

Recommendation#

Consider using names that meet container registry naming requirements. Additionally consider naming resources with a standard naming convention.

Examples#

Configure with Bicep#

To deploy registries that pass this rule, consider:

  • Set the name property to a string that matches the naming requirements.
  • Optionally, consider constraining name parameters with minLength and maxLength attributes.

For example:

Azure Bicep snippet
@minLength(5)
@maxLength(50)
@description('The name of the resource.')
param name string

@description('The location resources will be deployed.')
param location string = resourceGroup().location

resource registry 'Microsoft.ContainerRegistry/registries@2025-05-01-preview' = {
  name: name
  location: location
  sku: {
    name: 'Premium'
  }
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
    adminUserEnabled: false
    anonymousPullEnabled: false
    publicNetworkAccess: 'Disabled'
    zoneRedundancy: 'Enabled'
    policies: {
      quarantinePolicy: {
        status: 'enabled'
      }
      retentionPolicy: {
        days: 30
        status: 'enabled'
      }
      softDeletePolicy: {
        retentionDays: 90
        status: 'enabled'
      }
      exportPolicy: {
        status: 'disabled'
      }
    }
  }
}

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:

br/public:avm/res/container-registry/registry:<version>

To use the latest version:

br/public:avm/res/container-registry/registry:0.9.3

Configure with Azure template#

To deploy registries that pass this rule, consider:

  • Set the name property to a string that matches the naming requirements.
  • Optionally, consider constraining name parameters with minLength and maxLength attributes.

For example:

Azure Template snippet
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "name": {
      "type": "string",
      "minLength": 5,
      "maxLength": 50,
      "metadata": {
        "description": "The name of the resource."
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "The location resources will be deployed."
      }
    }
  },
  "resources": [
    {
      "type": "Microsoft.ContainerRegistry/registries",
      "apiVersion": "2025-05-01-preview",
      "name": "[parameters('name')]",
      "location": "[parameters('location')]",
      "sku": {
        "name": "Premium"
      },
      "identity": {
        "type": "SystemAssigned"
      },
      "properties": {
        "adminUserEnabled": false,
        "anonymousPullEnabled": false,
        "publicNetworkAccess": "Disabled",
        "zoneRedundancy": "Enabled",
        "policies": {
          "quarantinePolicy": {
            "status": "enabled"
          },
          "retentionPolicy": {
            "days": 30,
            "status": "enabled"
          },
          "softDeletePolicy": {
            "retentionDays": 90,
            "status": "enabled"
          },
          "exportPolicy": {
            "status": "disabled"
          }
        }
      }
    }
  ]
}

Notes#

This rule does not check if container registry names are unique.

Comments