You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Derive Entra redirect URIs from resource endpoints - #21151
Stacked on #21091. Adds WithRedirectUris(EndpointReference endpoint, params string[] callbackPaths) so redirect URIs follow a resource's endpoint instead of hard-coded literals.
Run mode: the URI is the allocated endpoint URL plus the callback path, passed as a Bicep parameter. DCP allocates endpoints before any workload starts, so Entra provisions with the real URLs first.
Publish/deploy:https:// plus the compute environment's GetHostAddressExpression (as Azure Front Door does) plus the path.
Callback path: can't be discovered, so the AppHost supplies it. It must start with / and match the consuming app's configuration. Gateways and custom domains keep using the literal or parameter overloads.
The EntraId playground now uses the new overload, so isolated runs register the actual ports.
Verified manually in run mode against a real Entra tenant: registered URIs matched the actual endpoints (including a random port that changed on restart) and sign-in redirect_uri values matched. Publish mode is covered only by a snapshot test with a fake compute environment.
Not covered yet (part of #21073): Web vs SPA platform, URI-count and .dev.localhost validation, duplicate-URI guard (Graph rejects duplicates with Request_BadRequest), and optional Graph diagnostics.
Add WithRedirectUris(EndpointReference, params string[] callbackPaths). Run mode uses the allocated endpoint URL; publish mode uses the compute environment host address. Callback paths are supplied by the AppHost. Update the EntraId playground to use it.
Fixes#21073
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 871660ba-8d46-4fb6-b76a-33b719ed42e7
When the dashboard or endpoint uses a *.dev.localhost name, the orchestrator makes the friendly URL primary. Entra matches such hosts exactly, so the redirect URI must use it instead of the allocated localhost URL.
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 871660ba-8d46-4fb6-b76a-33b719ed42e7
Remove the unrelated container app environment from the playground, give the Node front end the same registered origin, and add a publish test with a real container app environment plus a derived callback in the deployment scenario.
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 871660ba-8d46-4fb6-b76a-33b719ed42e7
Endpoint names alone do not identify an endpoint: a resource can display links to another resource's https endpoint. If its own endpoint link is DetailsOnly and a linked resource's HTTPS URL is shown in the summary, this filter selects the other resource's origin and registers callbacks on the wrong application. Match the endpoint's resource name as well, as ResourceBuilderExtensions.cs:2596–2599 does, and add a regression case with two endpoint owners.
Resolve callback origin after URL callbacks complete
This captures the origin before later URL callbacks run, making registration depend on fluent-call order. With a *.dev.localhost dashboard, calling WithRedirectUris(...) before web.WithUrlForEndpoint("https", u => u.Url = "/swagger") captures the friendly host. The orchestrator then resolves /swagger against the allocated localhost URL, so signing in from the final dashboard link uses an unregistered callback host. Resolve the origin after all URL callbacks and relative-URL normalization finish, without blocking that pipeline, and cover both call orders.
This case-sensitive reservation set allows a full-URI parameter named RedirectUri0 alongside the generated redirectUri0. Bicep rejects parameter names that differ only in casing with BCP353 because Azure Resource Manager cannot distinguish them, so this combination prevents registration provisioning. Use OrdinalIgnoreCase and extend the collision test to cover a case-variant parameter name in both call orders.
Match the owning resource when choosing the primary URL, complete with the allocated URL when no displayed URL remains, and use Task.WaitAsync for the timeout.
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 871660ba-8d46-4fb6-b76a-33b719ed42e7
Installed Version:17.0.0-pr.21151.g3a4657d3 (PR dogfood CLI from workflow run 39482644068)
Status: ✅ Verified
Changes Analyzed
Hosting changes: new WithRedirectUris(EndpointReference, params string[]) and WithRedirectUris(IResourceBuilder<ParameterResource> host, string, params string[]) overloads in Aspire.Hosting.Azure.EntraId; endpoint-derived URIs resolve from the allocated primary URL in run mode and from the compute environment host in publish/deploy.
Playground:playground/EntraId uses the endpoint overload.
Test changes: new unit tests and snapshots; the Entra deployment e2e scenario gains an endpoint-derived callback.
No CLI, Dashboard, template or CI infrastructure changes.
Covers run mode and publish mode, a real Container App Environment publish with the parent-module parameter wiring, *.dev.localhost primary URL, relative display URLs, URLs of another resource with the same endpoint name, cleared URLs, generated parameter names colliding with user parameters (both call orders), path validation (must start with /), and a single parameter still binding to the existing overload.
2. Publish with the PR CLI (no deployment)
Coverage Type: Happy path Status: ✅ Passed
Created an app from the PR build (Container Apps Express environment, Entra app, a consumer project) that registers an endpoint-derived URI, a host-parameter URI, a literal and a comma-separated parameter. aspire publish succeeded (11/11 steps) and generated:
Coverage Type: Happy path, end to end Status: ✅ Passed
aspire deploy of the app above succeeded (westus3, consumer at https://consumer.purpleplant-7a8a8aeb.westus3.azurecontainerapps.io). Reading the registration back through Microsoft Graph showed web.redirectUris:
The endpoint-derived URIs use the deployed consumer's host name, confirming the compute-environment host wiring and the dependency order.
4. Run mode against a real tenant (earlier commits)
Coverage Type: Happy path, boundary Status: ✅ Passed, on earlier commits of this branch
Ran the playground/EntraId AppHost locally against an Entra tenant: the registered URIs matched the allocated endpoints, including a random port that changed on restart, and sign-in redirect_uri values matched. With the dashboard on *.dev.localhost the registration used the friendly URL. This predates later review fixes to the run-mode URL capture (resource matching, cleared URLs, timeout handling); those are covered by unit tests (scenario 1) but were not re-run live.
CI Infrastructure Validation
Not applicable: no CI infrastructure changes.
Known Issue: Entra deployment e2e test
AzureEntraIdDeploymentTests currently fails on CI with a Microsoft Graph Forbidden (Authorization_RequestDenied) when creating the service principal. It fails identically on main and on the Oct 16 merge commit of the original Entra provisioning PR, with the same tenant and permissions as the Oct 15 passing run, so it is not caused by this PR. The extended scenario therefore could not be executed in CI; scenario 3 covers it manually.
Summary
Scenario
Status
Notes
Unit tests
✅ Passed
264/264
Publish with PR CLI
✅ Passed
Bicep as expected
Manual deploy + Graph check
✅ Passed
URIs match deployed host
Run mode, real tenant
✅ Passed
Earlier commits
Entra deployment e2e (CI)
⚠️ Blocked
Tenant-side Graph failure, also fails on main
Overall Result
✅ PR VERIFIED, with the CI deployment e2e blocked by an unrelated tenant issue.
Recommendations
Re-run AzureEntraIdDeploymentTests once the Graph issue is resolved.
Added a new Microsoft Entra ID integration page documenting the new WithRedirectUris(EndpointReference, params string[]) overload (and host-parameter overload) plus a sidebar entry. Triggered signal: integration_readme_changed (evidence: src/Aspire.Hosting.Azure.EntraId/README.md).
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
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
Stacked on #21091. Adds
WithRedirectUris(EndpointReference endpoint, params string[] callbackPaths)so redirect URIs follow a resource's endpoint instead of hard-coded literals.https://plus the compute environment'sGetHostAddressExpression(as Azure Front Door does) plus the path./and match the consuming app's configuration. Gateways and custom domains keep using the literal or parameter overloads.Verified manually in run mode against a real Entra tenant: registered URIs matched the actual endpoints (including a random port that changed on restart) and sign-in
redirect_urivalues matched. Publish mode is covered only by a snapshot test with a fake compute environment.Not covered yet (part of #21073): Web vs SPA platform, URI-count and
.dev.localhostvalidation, duplicate-URI guard (Graph rejects duplicates withRequest_BadRequest), and optional Graph diagnostics.Part of #21073
Checklist
<remarks />and<code />elements on your triple slash comments?Fixes: #21073