ARM, Automation, Azure, Professional

Easily Automating Azure Naming Standards via ARM Functions

One of the benefits of leveraging and automating ARM templates is the ability to apply a standard naming convention. Using the Cloud Adoption Framework’s as a baseboard we can develop a regional naming convention for Azure resources similar to:

<Resource Type>-<Service Name>-<Environment Name>-<Region Abbreviation>

This would translate into something like:

  • ase-website1-dev-eus
  • app-website1-dev-eus
  • appi-website1-dev-eus

By doing this we can quickly identify what type of resource, what is related to, it’s environment, and it’s region all by a quick glance.

The trick is how to automate this quickly and easily to ensure consistency. One way to do this is building ARM templates and using ARM Template Functions to fill in the blanks.

This can be accomplished by passing in just the environment and letting our template do the rest.

Here is an snippet of the parameter file. There would be a separate parameter for for each desired environment.

        "environment": {
            "value": "DEV"

The template will define the following parameters with default values. This will give us the flexibility to override if we’d like or just let the tempalte run as is with the desired defaults.

    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Location for all resources."
    "environment": {
      "type": "string",
      "defaultValue": "dev",
      "metadata": {
        "description": "The environment we will deploy code to"


The magic comes into using the ARM functions to auto populate what we need as variables:

"variables": {
    "systemName": "website1",
    "regionReference": {
      "centralus": "cus",
      "eastus": "eus",
      "westus": "wus"

"regionDeployment": "[toLower(variables('regionReference')[parameters('location')])]",

"appServicePlanName": "[toLower(concat('asp-', variables('systemName'),'-', parameters('environment'),'-',variables('regionDeployment')))]",

"webSiteName": "[toLower(concat('wapp-',variables('systemName'),'-',parameters('environment'),'-',variables('regionDeployment')))]",

"appInsightName": "[toLower(concat('appi-',variables('systemName'),'-',parameters('environment'),'-',variables('regionDeployment')))]",

Breaking down each piece section:

  • toLower() is used to standard cases since some azure resources like keyvault and storage accounts do no allow for upper case characters
  • systemName this is the name of the application we are inserting into the name of our Azure resources
  • concat() used to combine all the pieces of our name
  • ‘resourceTypeAbbreivation’ is the static abbreviation of the serivce type
  • environment is what we are passying in
  • regionDeployment is the real magic one

For regionDeployment we create an object region reference that is a two dimensional object mapping the regionname to an abbreviation. Our regionDeployment variable will take the parameter which by default is resourceGroup().location and look it up in the object returning the abbreviation. This will provide the flexibilty to override by passing it in as a parameter; however, a good practice is to map out resource groups by a combination of lifecycle and region as to self contain at the resource group level.

There we have it. By implementing these changes we can ensure a consistent and automated naming standard for our Azure resources.