ResourceModules
ResourceModules copied to clipboard
Create consistent naming conventions for resources
As a consumer of ResourceModules, I need to be able to create resources that must be globally unique and still maintain idempotency when continuously deploying the resource.
An example resource type can be azure storage account which needs to be a globally unique endpoint as it operates off DNS.
Using the uniqueString function can create a globally unique name.
We should remain consistent in all modules doing something like this

where "evhns-" is what is suggested in CAF here https://docs.microsoft.com/en-us/azure/cloud-adoption-framework/ready/azure-best-practices/resource-abbreviations
and the resourceGroup id is being used as the value to generate a unique string
To find a list of all resources that require a globally unique name, this doc can be useful here https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/resource-name-rules

From the discussion:
Suggest we try to align other naming with Azure Best Practices - Resource Naming - CAF docs
For generating globally unique names as default values of resources, we can generate it somewhat differently than today to have the deployment remain idempotent (today we are using basetime which will result in breaking idempotency). This is just as a suggestion, as we can also create a region map and environment map to provide 'prod' and 'weus' as shortened/abbriviated versions to use in names.
uniqueString(resourceGroup().id) -> 'tbppamxdtetns'
prefix from CAF docs:
eventhub namespace: 'evhns-'
Naming convention for default name generation for globally unique items could be:
'evhns-${uniqueString(resourceGroup().id)}'
Result:
'evhns-tbppamxdtetns'
Any references of uniqueString(basetime()) should be cleaned up in this issue as well
+1 to align to CAF. Customers constantly ask about recommendations and we usually refer them to the CAF naming doc. Worth applying this to our resources that we don't have names as mandatory
Autogenerate unique names feature will be removed.
@Dost2010 please add the proposed naming convention
Earlier we worked on AVD project and we came up with this logic for shortening region.
All name would contains regions, region would indicate which region resource is deployed. Logic for shortening region Guidance for Shortening Region names
If the region contains direction use the following short name
Direction Short name
North N
South S
East E
West W
Central C
South East SE
South West SW
North Central NC
South Central SC
If Region use Country name then shortened the country name followed by Region Direction Use Three Letter Abbreviation for the country name
Country /Region Abbreviation ASIA ASA United States US Canada CAN Europe EUR Australia AUS United Kingdom UK FRANCE FRA United Arab Emirates UAE KOREA KOR South Africa ZAF Brazil BRA EUROPE EU INDIA IND
So based on above Rule the following are Azure Regions with abbreviations
Region Abbreviation Eastasia EASA southeastasia SEASA centralus CUS eastus EUS eastus2 EUS2 westus WUS northcentralus NCUS southcentralus SCUS northeurope NEU westeurope WEU japanwest JPW japaneast JPE brazilsouth BRAS australiaeast AUSE (AUE australiasoutheast AUSSE (AUSE) southindia SIND centralindia CIND westindia WIND canadacentral CANC canadaeast CANE uksouth UKS ukwest UKW westcentralus WCUS westus2 WUS2 koreacentral KORC koreasouth KORS francecentral FRAC francesouth FRAS australiacentral AUSC australiacentral2 AUSC2 uaecentral UAEC uaenorth UAEN southafricanorth ZAFN southafricawest ZAW
Add more logic (Based on CAF) to the name as below Resource are provision as azure resource (for example host pool, workspace, or application security group). shortened that name
Resources are deployed as workload (for example resource belong to avd workload or resource deployed to webapp workload or sql workload. shortened that name
Resources are deployed as environment for example prod/test/dev(include shortened name of environment. add a post fix to make it unique and result is something like this
[ resource name shortened]-[workload name shortened]-[region shortened]-[name prefix] for example. nsg-avd-eus2-001 (network security group in avd workload, in east us 2 region )
We just discussed this in the grooming. The original issue was about the unique names and given them some sort of structure (e.g. using CAF). Following #1766 this won't be relevant anymore.
However, there may still be a use case to follow up on the issue. For example, we could add the CAF naming elements as optional parameters to the modules (i.e., region
,instance
, etc.) to the module interfaces. If no name is provided, and these instead, we could use them to build a name like nsg-avd-eus2-001
. Let's continue this discussion
Wait for the dependency approach, then we can discuss further. This issue is about test resource names.
-> And an update of the contribution guide
Duplicate, see #2038