Add context.azure.resourceNameHash for globally unique Azure recipe names - #12616
Add context.azure.resourceNameHash for globally unique Azure recipe names#12616AzureMike wants to merge 1 commit into
Conversation
…ames Azure Recipes passed raw Radius names to services that require globally unique names, so common names such as redis and rabbitmq failed with NameInUse. Add context.azure.resourceNameHash, which returns the first 16 lowercase hexadecimal characters of a SHA-256 hash over the lowercased Azure resource-group ID and Radius resource ID. Recipe Packs can combine this stable value with service-specific prefixes to derive unique Azure names for both Bicep and Terraform modules without wrapper modules. Supports radius-project/ai-extensions#128 Signed-off-by: Mike Azure <127820851+AzureMike@users.noreply.github.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Radius functional test overviewClick here to see the test run details
Test Status⌛ Building Radius and pushing container images for functional tests... |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #12616 +/- ##
==========================================
+ Coverage 54.11% 54.18% +0.06%
==========================================
Files 770 770
Lines 64518 51056 -13462
==========================================
- Hits 34914 27664 -7250
+ Misses 27001 20788 -6213
- Partials 2603 2604 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
kachawla
left a comment
There was a problem hiding this comment.
Was there a reason for computing this directly in buildContextLookup instead of adding resourceNameHash to the Azure recipe context schema? I was wondering whether it would be cleaner to compute it when the context is created and have the lookup map only expose the existing value. That would keep the context object and the context.* expression namespace consistent.
| } | ||
|
|
||
| // This stable hash avoids Azure name collisions while keeping redeployments stable. | ||
| // See https://github.com/radius-project/ai-extensions/issues/128. |
There was a problem hiding this comment.
nit: I'd recommend not putting github issue links in the code unless it's a TODO. We should add any relevant context in the comment here if we think more information is needed to explain the code.
Summary
Azure Recipes currently pass raw Radius names to services that require globally unique names, so common names such as
redisandrabbitmqfail withNameInUse.Direct Bicep and Terraform modules receive concrete parameters after Radius resolves Recipe context, which means they can't use Bicep's
uniqueString()with a Radius resource ID. This change addscontext.azure.resourceNameHash, which returns the first 16 lowercase hexadecimal characters of a SHA-256 hash over the lowercased Azure resource-group ID and Radius resource ID.The Azure Recipe Pack can combine this value with service-specific prefixes, giving each resource a stable Azure name without adding wrapper modules or limiting the fix to Bicep.
Validation
go test ./pkg/recipes/...Supports radius-project/ai-extensions#128