0
0
Azurecloud~5 mins

Resource naming conventions in Azure - Commands & Configuration

Choose your learning style9 modes available
Introduction
When you create resources in Azure, giving them clear and consistent names helps you find and manage them easily. Naming conventions solve the problem of confusion and mistakes when many resources exist.
When you create multiple virtual machines and want to identify their purpose and environment quickly
When you manage storage accounts and need to avoid name conflicts across Azure
When you organize resources by project, team, or environment to keep things tidy
When you automate deployments and want predictable resource names for scripts
When you monitor costs and want to track spending by resource type or department
Commands
This command creates a resource group named 'myResourceGroup-dev' in the East US region. The name includes the environment 'dev' to show it is for development.
Terminal
az group create --name myResourceGroup-dev --location eastus
Expected OutputExpected
{ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup-dev", "location": "eastus", "managedBy": null, "name": "myResourceGroup-dev", "properties": { "provisioningState": "Succeeded" }, "tags": null, "type": "Microsoft.Resources/resourceGroups" }
--name - Specifies the resource group name following naming conventions
--location - Sets the Azure region for the resource group
This command creates a storage account named 'mystorageacctdev01' in the 'myResourceGroup-dev' resource group. The name is lowercase, includes the environment, and ends with a number to ensure uniqueness.
Terminal
az storage account create --name mystorageacctdev01 --resource-group myResourceGroup-dev --location eastus --sku Standard_LRS
Expected OutputExpected
{ "accessTier": null, "creationTime": "2024-06-01T12:00:00Z", "customDomain": null, "enableHttpsTrafficOnly": true, "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup-dev/providers/Microsoft.Storage/storageAccounts/mystorageacctdev01", "kind": "StorageV2", "location": "eastus", "name": "mystorageacctdev01", "primaryEndpoints": { "blob": "https://mystorageacctdev01.blob.core.windows.net/", "file": "https://mystorageacctdev01.file.core.windows.net/", "queue": "https://mystorageacctdev01.queue.core.windows.net/", "table": "https://mystorageacctdev01.table.core.windows.net/" }, "primaryLocation": "eastus", "provisioningState": "Succeeded", "resourceGroup": "myResourceGroup-dev", "sku": { "name": "Standard_LRS" }, "tags": {}, "type": "Microsoft.Storage/storageAccounts" }
--name - Sets the storage account name following Azure naming rules
--resource-group - Associates the storage account with the resource group
--sku - Defines the performance and replication type
This command creates a virtual machine named 'myVM-dev-01' in the 'myResourceGroup-dev' group. The name includes the environment and a number for uniqueness.
Terminal
az vm create --resource-group myResourceGroup-dev --name myVM-dev-01 --image UbuntuLTS --admin-username azureuser --generate-ssh-keys
Expected OutputExpected
{ "fqdns": "", "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup-dev/providers/Microsoft.Compute/virtualMachines/myVM-dev-01", "location": "eastus", "name": "myVM-dev-01", "powerState": "VM running", "privateIpAddress": "10.0.0.4", "publicIpAddress": "52.170.12.34", "resourceGroup": "myResourceGroup-dev", "zones": "" }
--name - Names the VM with environment and unique number
--resource-group - Specifies the resource group for the VM
--generate-ssh-keys - Creates SSH keys for secure login
This command lists all resources in the 'myResourceGroup-dev' group in a table format to verify naming and organization.
Terminal
az resource list --resource-group myResourceGroup-dev --output table
Expected OutputExpected
Name ResourceGroup Location Type ------------------ ------------------ ---------- ------------------------------------------ myVM-dev-01 myResourceGroup-dev eastus Microsoft.Compute/virtualMachines mystorageacctdev01 myResourceGroup-dev eastus Microsoft.Storage/storageAccounts
--resource-group - Filters resources by the specified group
--output - Formats the output for easy reading
Key Concept

If you remember nothing else from this pattern, remember: consistent and clear resource names help you find, manage, and automate Azure resources easily.

Common Mistakes
Using uppercase letters or special characters in resource names
Azure resource names often require lowercase letters and no special characters, causing creation failures
Use only lowercase letters, numbers, and allowed characters as per Azure naming rules
Using generic names without environment or project info
Makes it hard to identify the resource purpose or environment, leading to confusion
Include environment (dev, prod) and project identifiers in names
Not ensuring uniqueness for global resources like storage accounts
Azure requires storage account names to be globally unique, so duplicates cause errors
Add numbers or unique suffixes to storage account names
Summary
Create resources with names that include environment and project info for clarity.
Use only allowed characters and lowercase letters to avoid errors.
Verify resource creation and naming by listing resources in the group.