Azure AI Search name must be valid

April 25, 2025 ยท View on GitHub

SYNOPSIS

Azure Resource Manager (ARM) has requirements for AI Search service names.

DESCRIPTION

When naming Azure resources, resource names must meet service requirements. The requirements for AI Search (previously known as Cognitive Search) service names are:

  • Between 2 and 60 characters long.
  • Lowercase letters, numbers, and hyphens.
  • The first two and last one character must be a letter or a number.
  • AI Search service names must be globally unique.

RECOMMENDATION

Consider using names that meet Azure AI Search service naming requirements. Additionally consider naming resources with a standard naming convention.

EXAMPLES

Configure with Bicep

To deploy AI Search services that pass this rule:

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

For example:

@minLength(2)
@maxLength(60)
@description('The name of the resource.')
param name string

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

resource search 'Microsoft.Search/searchServices@2023-11-01' = {
  name: name
  location: location
  identity: {
    type: 'SystemAssigned'
  }
  sku: {
    name: 'standard'
  }
  properties: {
    replicaCount: 3
    partitionCount: 1
    hostingMode: 'default'
  }
}

Configure with Azure template

To deploy AI Search services that pass this rule:

  • Set the name property to a string that matches the naming requirements.
  • Optionally, consider constraining name parameters with minLength and maxLength 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": "4357322963880451118"
    }
  },
  "parameters": {
    "name": {
      "type": "string",
      "minLength": 2,
      "maxLength": 60,
      "metadata": {
        "description": "The name of the resource."
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "The location resources will be deployed."
      }
    }
  },
  "resources": [
    {
      "type": "Microsoft.Search/searchServices",
      "apiVersion": "2023-11-01",
      "name": "[parameters('name')]",
      "location": "[parameters('location')]",
      "identity": {
        "type": "SystemAssigned"
      },
      "sku": {
        "name": "standard"
      },
      "properties": {
        "replicaCount": 3,
        "partitionCount": 1,
        "hostingMode": "default"
      }
    }
  ]
}

NOTES

This rule does not check if Azure AI Search service names are unique.