Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save maskati/590b5dd7d97b6ec4dd03e143f995063b to your computer and use it in GitHub Desktop.
Save maskati/590b5dd7d97b6ec4dd03e143f995063b to your computer and use it in GitHub Desktop.
Azure resource naming abbreviations, rules and restrictions

Microsoft documents recommended abbreviations for Azure resource types as well as resource type specific naming rules and restrictions. Microsoft also publishes the Azure Naming Tool which happens to contain a structured repository of Azure resource type abbreviations and naming rules.

You can get a quick searchable grid of this data using PowerShell. If you prefer you can replace the Windows-only Out-GridView with the cross platform Out-ConsoleGridView.

(irm https://raw.githubusercontent.com/mspnp/AzureNamingTool/main/src/repository/resourcetypes.json) `
|select resource,property,shortname,scope,lengthmin,lengthmax,validtext,invalidtext,invalidcharacters,regx `
|ogv -t 'Azure resource naming abbreviations, rules and restrictions'

image

Alternatively you can transform the source into a Json object indexed by resource type:

(irm https://raw.githubusercontent.com/mspnp/AzureNamingTool/main/src/repository/resourcetypes.json) `
|%{$x=[pscustomobject]::new()}{$x|add-member -notepropertyname "$($_.resource)$($_.property?" ($($_.property))":'')" -notepropertyvalue $_.shortname}{$x} `
|convertto-json|out-file resourcetypes.json

Which you can consume in your Bicep files: image

Warning

Doing this increases your final compiled template size somewhat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment