Enhance resource group naming with salt to avoid collisions and add t…#8529
Enhance resource group naming with salt to avoid collisions and add t…#8529banrahan wants to merge 3 commits into
Conversation
…ests for new functionality, fixes Azure#8528
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates the azure.ai.agents extension init flow to proactively avoid Azure Resource Group name collisions when multiple users (or multiple clones) scaffold the same template into the same subscription, by persisting and applying a random salt at project-scaffold time.
Changes:
- Refactors
ensureResourceTokenSaltto return the persisted salt (or empty string on best-effort failure). - Adds helpers to compose and persist a salted
AZURE_RESOURCE_GROUPvalue (rg-{envName}-{salt}) while respecting Azure’s 90-char RG limit. - Adds unit tests covering salted RG name composition and the new salt/RG persistence behaviors.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
cli/azd/extensions/azure.ai.agents/internal/cmd/init.go |
Generates/persists a salt and (best-effort) writes a salted AZURE_RESOURCE_GROUP during new project scaffolding to reduce RG collisions. |
cli/azd/extensions/azure.ai.agents/internal/cmd/init_test.go |
Adds test coverage for salted RG name composition and env persistence behavior. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Hey @banrahan, took a look at this. Reusing the salt pattern from #8488 keeps things consistent. Tests cover the edges: 78-char boundary, trailing dash/dot trimming, idempotence, skip-when-set, skip-when-empty-salt. A few small things:
Things I checked and are fine: 90-char limit math (3 + 78 + 1 + 8 = 90), the trailing Before this merges, I'd like @JeffreyCA or @vhvb1989 to give it a pass too. Thanks for picking this up. |
fixes #8528
Mirrored PR #8488's salt approach to the resource group name:
Refactored ensureResourceTokenSalt to return its salt and added composeSaltedResourceGroupName + ensureResourceGroupName helpers that write a salted AZURE_RESOURCE_GROUP (e.g. rg-{envName}-{salt}) into the azd environment at new-project scaffold time.
The composition truncates the env name first so the 8-char salt is always preserved within Azure's 90-char RG limit, and the whole thing is best-effort/idempotent. Skipping when salt is empty or AZURE_RESOURCE_GROUP is already set, falling back cleanly to Bicep's original rg-${environmentName} default.