Azure naming · Microsoft.Compute/virtualMachines

vm Virtual machine

An Azure virtual machine. The portal uses the resource name as the guest host name, so the host-name rules apply in practice.

Naming constraints

CAF abbreviationvm
Resource typeMicrosoft.Compute/virtualMachines
Length1–64 characters
CaseMixed case
Allowed charactersLetters, numbers, and hyphens. No underscores or periods. Can't start or end with a hyphen.
Uniqueness Resource group
Windows host namemax 15 characters
SeparatorHyphen
Watch out: The resource name can be up to 64 characters, but the host name is capped at 15 on Windows (no periods) and 64 on Linux, and underscores and periods aren't allowed. The portal uses one value for both, so keep VM names host-name safe and 15 characters or less for Windows.

Source: Microsoft Learn, “Naming rules and restrictions for Azure resources”, checked October 2026. Abbreviation from the Cloud Adoption Framework.

Example & copy-ready

A worked name for workload app, env prod, region weu, instance 001.

Example name
vm-app-prod-weu-001 Valid

⚠ 19 characters is over the 15-character Windows host name limit.

Validation regex for CI checks or pre-commit hooks (.NET and JavaScript)
^(?=.{1,64}$)[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?$
Bicep naming expression
var name = take('vm-${workload}-${env}-${region}-${instance}', 64)
Terraform local
locals {
  name = substr(join("-", compact(["vm", var.workload, var.env, var.region, var.instance])), 0, 64)
}

Azure Policy can't evaluate regular expressions, so a policy can check the vm prefix but not the full format. Run the regex in your pipeline, or audit existing names on a schedule.

Uniqueness scope

Unique within the parent resource group. The same name can be reused in a different resource group.

Open in the name generator