Skip to content

Add context.azure.resourceNameHash for globally unique Azure recipe names - #12616

Open
AzureMike wants to merge 1 commit into
mainfrom
azuremike/azure-resource-name-hash
Open

Add context.azure.resourceNameHash for globally unique Azure recipe names#12616
AzureMike wants to merge 1 commit into
mainfrom
azuremike/azure-resource-name-hash

Conversation

@AzureMike

Copy link
Copy Markdown
Contributor

Summary

Azure Recipes currently pass raw Radius names to services that require globally unique names, so common names such as redis and rabbitmq fail with NameInUse.

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 adds 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.

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

…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>
@AzureMike
AzureMike requested review from a team as code owners August 4, 2026 20:56
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@radius-functional-tests

radius-functional-tests Bot commented Aug 4, 2026

Copy link
Copy Markdown

Radius functional test overview

🔍 Go to test action run

Click here to see the test run details
Name Value
Repository radius-project/radius
Commit ref 4e0f541
Unique ID funcc0a6db0802
Image tag pr-funcc0a6db0802
  • Dapr: 1.14.4
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.3.0
  • Bicep recipe location ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/<name>:pr-funcc0a6db0802
  • Terraform recipe location http://tf-module-server.radius-test-tf-module-server.svc.cluster.local/<name>.zip (in cluster)
  • applications-rp test image location: ghcr.io/radius-project/dev/applications-rp:pr-funcc0a6db0802
  • dynamic-rp test image location: ghcr.io/radius-project/dev/dynamic-rp:pr-funcc0a6db0802
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-funcc0a6db0802
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-funcc0a6db0802
  • deployment-engine test image location: ghcr.io/radius-project/deployment-engine:latest

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting corerp-cloud functional tests...
⌛ Starting ucp-cloud functional tests...
✅ ucp-cloud functional tests succeeded
✅ corerp-cloud functional tests succeeded

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Unit Tests

    2 files  ±0    457 suites  ±0   7m 23s ⏱️ -7s
6 202 tests +6  6 200 ✅ +6  2 💤 ±0  0 ❌ ±0 
7 431 runs  +6  7 429 ✅ +6  2 💤 ±0  0 ❌ ±0 

Results for commit 4e0f541. ± Comparison against base commit b6eb465.

@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 54.18%. Comparing base (6a5647d) to head (4e0f541).
⚠️ Report is 4 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kachawla kachawla left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants