If you host anything in Azure, then you've probably had to think about resource naming conventions, even if your convention is not to have one! But any time you start building up a sizable collection of resources, having a naming convention can make it a lot easier to manage.

Microsoft have a suggested convention as part of their Cloud Adoption Framework. It's pretty straightforward, and makes use of their list of recommended abbreviations for resource types.

I thought I'd have a go making a simple tool that could automate generating the name. There's lots of ways I could have built such a tool, but I figured a simple web page should be achievable and make it accessible to most people.

Most of my time is spent working on back-end code, so here was a chance to play around with a frontend framework. I could have chosen one of the big names, but there's one I've been keeping a keen eye on for a long time that I hadn't ever actually used - Aurelia - and this seemed like a nice opportunity to kick the tyres. I was really pleased with the result. This is not a complicated web application, but I do like the way Aurelia works. I used Aurelia v1, but I'll be keen to upgrade to v2 (it's currently in alpha).

You can try out the tool at https://david.gardiner.net.au/azure-resource-namer/, with the source code at https://github.com/flcdrg/azure-resource-namer. I made use of GitHub Pages for the publishing part. Later on I might get a custom domain and maybe run it with something like Azure Static Web Apps, but this does the job for now.

Screenshot

The naming convention consists of concatenating a number of fields together:

  • The Resource Type and Region fields are drop-down lists.
  • The Workload and Environment fields are user-editable. The type of resource will determine what characters are allowed here.
  • The Instance field is numeric. If you set it to zero then it will be excluded.

There are a lot of different resource types. The tool supports all the types listed in the previously mentioned abbreviations page. I'm slowly adding extra validation information for each resource, so that you get extra hints should you use an invalid character, the name ends up being too long, and also where there are particular formatting requirements (eg storage accounts).

Screenshot of invalid character

Screenshot of invalid too long

The resource types are listed in resources.ts. For example here's how the rules and information for the 'Resource Group' resource type has been defined:

{
    abbrev: 'rg',
    name: 'Resource group',
    minLength: 1,
    maxLength: 90,
    // https://docs.microsoft.com/en-us/rest/api/resources/resource-groups/create-or-update#uri-parameters
    regex: /^[-\w\._\(\)]+$/,
    description: 'Alphanumerics, underscores, parentheses, hyphens, periods, and unicode characters that match the regex documentation. Can\'t end with period.'
}

Once I've got all the resource type rules done, there's probably scope for more customisation options and other enhancements. I've already had one of my SixPivot colleagues Dylan contribute the 'copy to clipboard' button.

Give it a try and let me know what you think in the comments. If you've got some ideas or would like to contribute additional features, head over to the repo!