Naming of Azure Resources (Part 1)

 


Context

In most demos and tutorials about Azure (and not just that) you will find a variety of resources provisioned in "fast / light" mode, that is to say without being super strict on concepts such as naming artifacts. "WebApp1", "MyVM", "MyRG" are names commonly found in demonstrations or even the "Proof-of-Concepts" (which are supposed to be much more than basic demos).
No particular concern at this point, we're supposed to be focused on the principles and concepts of the demo involved. But what about what about naming Azure artifacts when moving to a real project or an application to put into production? How do we ensure that the names we choose will be well in tune with the architectural complex context, environment, safety, operation of this application, project or system?

Naming in IT projects

First, the notion of strict naming is not specific to Azure; each IT project should follow a set of naming rules, rules that will help to properly structure the project, easily find the terms we already knew before, or even be able to identify resources exposed in lists not always structured. Naming rules are present in each programming language, in each infrastructure provisioning.
That said, there are concepts specific to the cloud (even specific to Azure) which will complement the already existing concepts. We must first catalog the list of naming aspects that is applicable for our organization, our project and our cloud.
Key principles:
Today, who said cloud, said agile mind. The cloud itself (and the public cloud in particular) is agile by his speed provisioning, scaling elasticity, and especially its fast pace of updates and new features. To respect this spirit, rules must accept flexibility. One should not be blocked to deploy a prototyping environment because, for example, the project name has not been clearly defined, or the type of artifact or resource is fresh in the cloud; however, even in this case, we should be able to easily understand afterwards in what context the resource was provisioned (if only for environment deprovisioning to avoid Azure consumption). This article will not try, so, to impose a set of rules as universal, but rather guide you how to define your own set of rules and then apply. That said, we still try to exemplify concretely (and for those who will see the example very close to their cases, apply directly the model in its state). Finally, the last "disclaimer", the dynamic spirit of the Azure will make possible that certain rules or constraints no longer apply (or are different) at the time of reading. In this case, a feedback from you will be very useful for the update of the article.  

What’s a name of an Azure resource?

Let’s start from the base: the name of a resource Azure represents a string which allows unique identification of the Azure resource.
The very general vision of this definition stops here:
  • The name itself can be a simple "code" unique, or may correspond to a "namespace" (ex. Azure Service Bus), an "account name" (ex. Azure Storage), a "hostname" (ex. Azure VM) or other specific significance to the type of resource
  • Unique identification, where? Names can have a context (scope) global public (eg. Based on an Azure subdomain, like the Azure Service Bus namespaces, Azure Storage accounts etc.), local to the subscription (eg. Azure VNET) or local to the parent resource (ex. the names of files or blobs in Azure Blob Storage container)
    • To further complicate the task, some types of resources have naming rules different for different types within the same type (difficult to understand? example: the Azure VMs have stronger constraints - maximum 15 characters - for VMs based on Windows, than on Linux. Historical issue, of course, coming from on-premises infrastructure, but that is reflected in the cloud naming).
  • The characters allowed in names also vary; but we can identify some sets of applicable characters - like below (but not limited to):
    • Alphanumeric (numbers and letters)
    • Alphanumeric plus underscore and dash
    • Alphanumeric plus underscore, dash and dot
    • Any character allowed in a URI
    • Any character
  • The majority of names cannot begin or end with a hyphen or underscore
  • Also, a particular point is the variability of case sensitivity:
    • Case sensitive names (ex. blob names in Azure Storage container)
    • Case insensitive names (eg. resource groups)
    • Mandatory lowercase names (eg. the Azure Storage accounts)
  • Length constraints are widely varying – both on the lower limit and the upper one. Certain names require between 1-64 characters other between 1-80, 2-80, 1-1024 etc.. Very, very variable, therefore, no specific marker on this.
On the whole, unfortunately there isn’t an overall view (regarding Azure, here, but AWS is suffering the same punishment, for that matter) - no overview of consolidated and (more) uniform naming rules for artifacts and resources.
Hence once again the importance of this naming structuring task. It is not unusual that you start with the rules that you consider sufficient (for the types of resources you deal with at that time) and which fall blocking for the naming of the very new resource you need in your project).

Naming constraints for Azure resources

To give you a more accurate and centralized reference for these constraints, here they are (compiled from the Azure documentation and following the requirements outlined in the resources creation process):

Resource or artifact Context (Scope) Min len Max len Case Valid character set
Resource Group Global 1 64 Insensitive Alphanumeric, underscore and hyphen
Availability Set Resource Group 1 80 Insensitive Alphanumeric, underscore and hyphen
Virtual Machine (Windows) Resource Group 1 15 Insensitive Alphanumeric, underscore and hyphen
Virtual Machine (Linux) Resource Group 1 64 Insensitive Alphanumeric, underscore and hyphen
Storage account Global 3 24 Lower cap Alphanumeric
Azure Storage Container Storage account 3 63 Lower cap Alphanumeric and hyphen
Azure Storage Blob Container 1 1024 Sensitive URL characters
Azure Storage Queue Storage account 3 63 Lower cap Alphanumeric and hyphen
Azure Storage Table Storage account 3 63 Insensitive Alphanumeric
Azure Storage File Storage account 3 63 Lower cap Alphanumeric
Virtual Network (VNet) Resource Group 2 64 Insensitive Alphanumeric, underscore, hyphen and point
Network Subnet Parent VNet 2 64 Insensitive Alphanumeric, underscore, hyphen and point
Network Interface Resource Group 1 80 Insensitive Alphanumeric, underscore, hyphen and point
Network Security Group Resource Group 1 80 Insensitive Alphanumeric, underscore, hyphen and point
Network Security Group Rule Resource Group 1 80 Insensitive Alphanumeric, underscore, hyphen and point
Route table Resource Group 1 80 Insensitive Alphanumeric, underscore, hyphen and point
ExpressRoute Circuit Resource Group 1 80 Insensitive Alphanumeric, underscore, hyphen and point
Public IP Address Resource Group 1 80 Insensitive Alphanumeric, underscore, hyphen and point
Load Balancer Resource Group 1 80 Insensitive Alphanumeric, underscore, hyphen and point
Load Balanced Rules Config Load Balancer 1 80 Insensitive Alphanumeric, underscore, hyphen and point
App Service Plan Subscription 2 40 Insensitive Alphanumeric
Web App Global 2 60 Insensitive Alphanumeric and hyphen
Function Global 2 60 Insensitive Alphanumeric and hyphen
Mobile App Global 2 60 Insensitive Alphanumeric and hyphen
Logic App Global 2 60 Insensitive Alphanumeric and hyphen
API App Global 2 60 Insensitive Alphanumeric and hyphen
App Service Environment Global 2 60 Insensitive Alphanumeric and hyphen
App Service Certificate Global 3 15 Insensitive Alphanumeric
API Management Global 1 50 Insensitive Alphanumeric
Notification Hub Subscription 1 260 Insensitive Alphanumeric, underscore, hyphen and point
Notification Hub Namespace Global 2 50 Insensitive Alphanumeric and hyphen
SQL Database Subscription 1 28 Insensitive Alphanumeric, underscore and hyphen
SQL Server Global 1 63 Lower cap Alphanumeric and hyphen
SQL Data Warehouse Database Subscription 1 28 Insensitive Alphanumeric, underscore and hyphen
Document DB Global 3 50 Lower cap Alphanumeric and hyphen
Redis Cache Global 1 63 Insensitive Alphanumeric and hyphen
Search Service Global 2 60 Lower cap Alphanumeric and hyphen
Power BI Workspace Collection Subscription 3 64 Insensitive Alphanumeric and hyphen
Cognitive Services Account Subscription 2 64 Insensitive Alphanumeric, underscore and hyphen
Data Catalog Subscription 2 26 Insensitive Alphanumeric
HDInsight Cluster Global 1 59 Insensitive Alphanumeric and hyphen
Machine Learning Workspace Subscription 3 24 Insensitive Alphanumeric and hyphen
Data Factory Subscription 3 64 Insensitive Alphanumeric and hyphen
Event Hub Subscription 1 50 Insensitive Alphanumeric, underscore and hyphen
Service Bus Namespace Global 6 50 Insensitive Alphanumeric and hyphen
Service Bus Queue Subscription 1 50 Insensitive Alphanumeric, underscore and hyphen
Service Bus Topic Subscription 1 50 Insensitive Alphanumeric, underscore and hyphen
Stream Analytics Job Subscription 3 63 Insensitive Alphanumeric and hyphen
IoT Hub Subscription 3 50 Insensitive Alphanumeric and hyphen
Traffic Manager Global 1 63 Insensitive URL characters
Media Service Account Global 3 24 Lower cap Alphanumeric
CDN Profile Global 1 ? Insensitive Alphanumeric and hyphen
Azure AD Domain Global 1 27 Insensitive Alphanumeric
Azure AD Subscription 1 256 Insensitive Any character
Team Services Account Global 1 50 Insensitive Alphanumeric and hyphen
Team Project Account 1 65 Insensitive Alphanumeric and hyphen
DevTest Labs Subscription 1 27 Insensitive Alphanumeric, underscore, hyphen and parenthesis
Application Insights Subscription 1 255 Insensitive Any except 3 characters
Automation Account Subscription 6 50 Insensitive Alphanumeric and hyphen
Recovery Services Vault Subscription 2 50 Insensitive Alphanumeric and hyphen
Scheduler Job Subscription 1 260 Insensitive Alphanumeric, underscore and hyphen
Scheduler Job Collection Subscription 1 100 Insensitive Alphanumeric, underscore and hyphen
Cloud Service Global 1 63 Insensitive Alphanumeric and hyphen
Batch Account Global 3 24 Lower cap Alphanumeric
BizTalk Service Global 6 20 Lower cap Alphanumeric
Mobile Engagement Collection Global 2 50 Insensitive Alphanumeric and hyphen
Mobile Engagement App Resource Global 1 50 Insensitive Alphanumeric, underscore and hyphen
Mobile Engagement Application Subscription 1 ? Insensitive Any character
RemoteApp Collection Subscription 3 13 Insensitive Alphanumeric
Key Vault Global ? ? Insensitive Alphanumeric and hyphen
Operations Mgmt Suite Namespace Global 4 24 Insensitive Alphanumeric and hyphen
Tag Name Resource 1 512 Insensitive Alphanumeric
Tag Value Resource 1 256 Insensitive Alphanumeric

Follow-up

This first article about the naming of Azure resources and artifacts will be followed soon by other items, which will include details of the aspects or particles included in the names, reference charts of particles, composition rules and the good practices. Note: you will find the French version of this article at: http://blog.cellenza.com/cloud-2/azure/partie-1-nommage-ressources-azure/.







Azure App Service Environment – error on creating a new Web App

When creating a new Web App hosted inside an App Service Environment (ASE) via an ARM template, you may encounter the following error:

"Resource Microsoft.Web/sites 'yourapplication-web01' failed with message 'Server farm with name yourappserviceplan not found.' ". Here is the reference line in the template: "serverFarmId": "/subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx/resourceGroups/yourresourceid/providers/Microsoft.Web/serverfarms/ yourappserviceplan".

(where: yourapplication-web01 = the name of your web app,  yourresourceid = the name of your resource group, yourappserviceplan = the name of your app service hosting plan)

This error comes usually from an insufficient information in the ARM template you are trying to deploy. If in a Web App deployment outside ASE it is enough to reference the hosting plan which hosts the application, within an ASE you need to specify also the information for referencing the ASE environment which includes the hosting plan:

[template segment for the web app definition]

  {

      "apiVersion": "2015-08-01",
      "name": "[parameters('siteName')]",
      "type": "Microsoft.Web/sites",
      "location": "[parameters('location')]",
      "tags": {
        "displayName": "[parameters('siteName')]"
      },
      "properties": {
        "name": "[parameters('siteName')]",
        "hostingEnvironment": "[parameters('environmentName')]",
        "hostingEnvironmentId": "[resourceId('Microsoft.Web/hostingEnvironments', parameters('environmentName'))]",
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]"
      }
    }

So for the parametering aspect, you will need to include the hosting plan name ('hostingPlanName') as well as the ASE name ('environmentName').

Note: if the web site will be deployed in a different resource group, then you will need to qualify the resource references with their resource group name:
"serverFarmId": "[resourceId(parameters('hostingPlanResourceGroupName'), 'Microsoft.Web/serverfarms', parameters('hostingPlanName'))]"

That’s all. Have a good deployment!