How to name Azure Storage Accounts? [closed]
Asked Answered
F

2

14

Azure Storage Account name length restriction throws a wrench in what could be something easy. Being able to name my resources per tenant, like rg{tenant-guid} for a resource group, or fa{tenant-guid} for a function app is nice and easy, but a 24-character limit on azure storage accounts really mucks it all up. Why put a requirement for a globally-unique name on Azure Storage Accounts and not allow administrators to use GUID's for naming Azure Storage Accounts?

Partly question, mostly rant.

Frederiksen answered 6/1, 2021 at 17:7 Comment(0)
T
0

If you have a continuous deployment solution, the GUID will not work correctly for you because it will be regenerated every time you deploy. Instead, using uniqueString() with a known seed will provide a consistent name that can work correctly in a CD scenario.

A solution we've used for years and has worked fine has been to name our storage accounts with a uniquestring based on the resourcegroup name and trimming to 24 chars.

We have a baseName for all resources that will be deployed on resourceGroup and the following formula gives us a unique storage account name that is deterministic and can be used on CD.

"storageAccountName": "[take(concat(replace(parameters('baseName'),'-',''), uniquestring(resourceGroup().id)),24)]",
Tho answered 28/2 at 19:6 Comment(1)
This is the exact same solution that I provided in the original post. We generate a tenantId, and then use that tenantId as the baseName for all related resources (We do not re-generate a guid on every deployment, that wouldnt make any sense)Frederiksen
A
-1

This is just a limitation like all the other services . There are different factors considered and this is common with any clound vendor as well.

The only reason these naming restrictions exist are because the storage account name gets put in the URL so it has to be unique and should not contain GUIDs. You can use uniqueString() to generate storage account names

Aerator answered 6/1, 2021 at 17:22 Comment(2)
While I partially agree that URL's should not contain GUID's - it only really boils down to a matter of aesthetics/readability. Using a uniqueString() for a URL is, in effect, the same thing - A random assortment of characters and numbers that doesn't provide any level of readability over a GUID.Frederiksen
URLs should be able to contain hyphens but those are also forbidden in a storage account name.Cheerful

© 2022 - 2024 — McMap. All rights reserved.