Generated names for azure resources with global name scope aren't always unique
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
Most of the names generated for azure resources do something like `take(name + uniqueString, maxLength)` which means it's not unique if `name` is longer than `maxLength`.
This is particularly bad, because you only find out about this when you do a new deployment of the project, and it might be too late to change the name if the first deployment is used in production.
I suggest the generated name be more like `take(name, maxLength - 13) + uniqueString`. There's still potential for a conflict within a project (because they'll have the same `uniqueString`), but this will be figured out on the first deployment before it's being relied upon.
This was discussed in https://github.com/dotnet/aspire/discussions/12652, but I didn't get a conclusive answer where this should be fixed, so I'm raising it here as a starting point.
This is related to https://github.com/dotnet/aspire/issues/5756 cc @eerhardt
The most likely to hit this is storage accounts with their 24 char limit, but ServiceBus namespaces and SQL servers are also candidates in our project at least.
### Expected Behavior
I expect to be able to deploy a second instance of my project to a separate resource group without conflict.
### Steps To Reproduce
add
```csharp
builder.AddAzureStorage("namegreaterthan24charslong")
```
and try to deploy it to two different resource groups in Azure.
### Exceptions (if any)
_No response_
### .NET Version info
_No response_
### Anything else?
```xml
```
Contributor guide
Assessment
This issue has not been assessed yet.