Azure VM Naming Conventions: Resource Name vs Computer Name
How to name Azure virtual machines with CAF: the 64-character resource name, the 15-character Windows computer name, VMSS prefixes, and Terraform/Bicep examples.
An Azure VM resource name can be up to 64 characters, so a CAF name like
vm-payments-prod-eus-001fits comfortably. The computer name inside the OS is a separate value with much tighter limits: 15 characters on Windows, 64 on Linux. Keep the full CAF name on the resource and set a short computer name explicitly in your IaC.
Virtual machine naming causes more confusion than any other Azure resource, and it comes down to one fact most people learn the hard way: a VM has two names, not one.
The two names
The resource name is what Azure Resource Manager knows the VM by. It appears in the portal, in az vm list, in your Terraform state, and in resource IDs. It can be up to 64 characters, letters, numbers, and hyphens, which is plenty for a full CAF name.
The computer name (host name) is what the operating system calls itself. It’s what hostname returns, what NetBIOS and Active Directory see on Windows, and what DNS inside your VNet resolves. Windows caps it at 15 characters. Linux allows up to 64, but can’t end with a period or hyphen.
The reason these get conflated: when you create a VM in the portal, Azure uses the single name you type for both. Type more than 15 characters for a Windows VM and the portal rejects it, which is why so many teams believe the VM naming limit is 15. It isn’t. Only the computer name is.
The CAF pattern
Use the standard pattern for the resource name, exactly like any other resource:
vm-{workload}-{environment}-{region}-{instance}
| Scenario | Resource name |
|---|---|
| Payments API server, production | vm-payments-prod-eus-001 |
| Second instance | vm-payments-prod-eus-002 |
| Jump box, West Europe | vm-jumpbox-prod-weu-001 |
| Build agent, dev | vm-buildagent-dev-eus-001 |
For the computer name, define a separate, shorter scheme that fits 15 characters. Drop the hyphens and abbreviate:
| Resource name | Computer name (Windows) |
|---|---|
vm-payments-prod-eus-001 | vmpayprod001 |
vm-jumpbox-prod-weu-001 | vmjbxprod001 |
vm-buildagent-dev-eus-001 | vmblddev001 |
Document the abbreviation scheme next to your naming convention, otherwise every engineer invents their own.
Setting both names in Terraform
The azurerm provider exposes the computer name explicitly. If you omit it, Terraform derives it from the resource name and fails when that exceeds the OS limit:
resource "azurerm_windows_virtual_machine" "app" {
name = "vm-payments-prod-eus-001" # resource name, up to 64
computer_name = "vmpayprod001" # host name, max 15 on Windows
resource_group_name = azurerm_resource_group.main.name
location = azurerm_resource_group.main.location
size = "Standard_D2s_v5"
# ...
}
Linux gives you more room, but setting it explicitly keeps host names predictable:
resource "azurerm_linux_virtual_machine" "app" {
name = "vm-payments-prod-eus-002"
computer_name = "vmpayprod002"
# ...
}
In Bicep, the computer name lives in the OS profile:
resource vm 'Microsoft.Compute/virtualMachines@2024-07-01' = {
name: 'vm-payments-prod-eus-001'
location: resourceGroup().location
properties: {
osProfile: {
computerName: 'vmpayprod001'
// ...
}
}
}
Scale sets: the 9-character prefix
Virtual machine scale sets add one more constraint. Each instance gets a numeric suffix appended to a computer name prefix, and on Windows that prefix is capped at 9 characters:
resource "azurerm_windows_virtual_machine_scale_set" "workers" {
name = "vmss-payments-prod-eus-001" # resource name, up to 64
computer_name_prefix = "vmsspay" # max 9 on Windows
# instances become vmsspay000001, vmsspay000002, ...
}
Keep the scale set’s resource name in full CAF form and design the prefix separately.
Naming the resources around a VM
A VM never travels alone. Name its companions so they sort next to it:
| Resource | CAF prefix | Example |
|---|---|---|
| Virtual machine | vm | vm-payments-prod-eus-001 |
| Network interface | nic | nic-vm-payments-prod-eus-001 |
| Public IP | pip | pip-vm-payments-prod-eus-001 |
| OS disk | osdisk | osdisk-vm-payments-prod-eus-001 |
| Data disk | disk | disk-vm-payments-prod-eus-001-data01 |
| NSG | nsg | nsg-vm-payments-prod-eus-001 |
Embedding the full VM name in each companion makes portal searches trivial: search vm-payments-prod-eus-001 and everything belonging to that VM appears.
Common mistakes
Designing the whole convention around 15 characters. Teams cripple their entire naming scheme to fit the Windows computer name limit. Keep the rich 64-character resource name and shorten only the computer name.
Letting the portal set both names. Portal-created VMs get identical resource and computer names, which means you lose the CAF structure or hit the 15-character wall. Create VMs through IaC and set both explicitly.
Renaming plans. VMs cannot be renamed, either name, without recreating the VM. Get both names right before the first deployment.
Summary
- Resource name: up to 64 characters, use the full CAF pattern
vm-workload-env-region-instance - Computer name: 15 characters on Windows, 64 on Linux, set it explicitly in IaC with a documented short scheme
- VMSS Windows computer name prefix: 9 characters
- Name NICs, disks, IPs, and NSGs after the VM they belong to
The full rules are on the virtual machine naming page, and AzureNamer generates the resource name with a reminder about the computer name limits whenever you select a VM or scale set. See the complete CAF guide for the pattern behind the prefix.
Keep reading
Azure App Service and Function App Naming Conventions
CAF naming for web apps, function apps, App Service plans, and slots: the azurewebsites.net hostname rules, the 32-character Functions host ID gotcha, and IaC examples.
Read →Azure API Management Naming Conventions: Service, APIs, and Products
CAF naming for Azure API Management. The service is a globally unique azure-api.net endpoint (1 to 50 chars); APIs, products, backends, and named values inside are function-named. Patterns and examples.
Read →Azure Service Bus Naming Conventions: Namespaces, Queues, and Topics
CAF naming for Azure Service Bus. The namespace is a globally unique servicebus.windows.net endpoint (6 to 50 chars); queues, topics, and subscriptions inside are relaxed. Patterns and examples.
Read →Try AzureNamer
Generate CAF compliant names for all 200+ Azure resource types, free, no login required.
Open the Generator →