Fix transitive Azure role assignments through WaitFor dependencies#14473
Merged
eerhardt merged 2 commits intorelease/13.2from Feb 12, 2026
Merged
Fix transitive Azure role assignments through WaitFor dependencies#14473eerhardt merged 2 commits intorelease/13.2from
eerhardt merged 2 commits intorelease/13.2from
Conversation
Remove CollectAnnotationDependencies calls from CollectDependenciesFromValue to prevent WaitFor/parent/connection-string-redirect annotations from referenced resources being included as direct dependencies of the caller. Add tests verifying: - DirectOnly mode excludes WaitFor deps from referenced resources - WaitFor doesn't create transitive role assignments in Azure publish Co-authored-by: eerhardt <8291187+eerhardt@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix transitive role assignment to Azure resources
Fix transitive Azure role assignments through WaitFor dependencies
Feb 12, 2026
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14473Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14473" |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where Azure role assignments were incorrectly created for transitive dependencies through WaitFor relationships. When webfrontend referenced server (which had a WaitFor dependency on cache), the webfrontend incorrectly received role assignments to the cache resource.
Changes:
- Removed incorrect
CollectAnnotationDependenciescalls fromCollectDependenciesFromValueinResourceExtensions.csthat were leaking transitive WaitFor/Parent/Redirect dependencies into DirectOnly dependency discovery mode - Added unit test verifying that DirectOnly mode excludes WaitFor dependencies from referenced resources
- Added integration test confirming Azure role assignments are not created for transitive WaitFor dependencies
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs | Removed two CollectAnnotationDependencies calls from CollectDependenciesFromValue that incorrectly collected annotation-based dependencies (WaitFor, Parent, Redirect) from resources discovered through value traversal |
| tests/Aspire.Hosting.Tests/ResourceDependencyTests.cs | Added test DirectOnlyDoesNotIncludeWaitForDependenciesFromReferencedResources verifying that DirectOnly mode correctly excludes transitive WaitFor dependencies |
| tests/Aspire.Hosting.Azure.Tests/RoleAssignmentTests.cs | Added test WaitForDoesNotCreateTransitiveRoleAssignments verifying the exact bug scenario: server with cache dependency should get role assignment, but webfrontend referencing server should not |
karolz-ms
approved these changes
Feb 12, 2026
Member
|
/backport to main |
Contributor
|
Started backporting to main: https://github.com/dotnet/aspire/actions/runs/21964924265 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
CollectDependenciesFromValueinResourceExtensions.cswas callingCollectAnnotationDependencieson resources discovered through env var/argument value traversal. This leakedWaitAnnotation(and parent/redirect) dependencies from referenced resources into the caller's dependency set — even inDirectOnlymode used byAzureResourcePreparer.GetAzureReferences.Result:
webfrontend → server (WaitFor cache)produced a spuriouswebfrontend-roles-cache.bicep.Fix: Remove
CollectAnnotationDependenciescalls fromCollectDependenciesFromValue. Annotation-based dependencies are already collected:GatherDirectDependenciesAsync→CollectAnnotationDependenciesRecursivemode, via the recursive loop inGetResourceDependenciesAsyncChecklist
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
aka.ms/usr/local/bin/bicep /usr/local/bin/bicep build /tmp/aspire-bicepOKDnzw/env-acr.module.bicep --stdout(dns block)/usr/local/bin/bicep /usr/local/bin/bicep build /tmp/aspire-bicepfw1kQr/teststorage.module.bicep --stdout(dns block)/usr/local/bin/bicep /usr/local/bin/bicep build /tmp/aspire-bicepDgmTIe/env.module.bicep --stdout(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.