Repository navigation
Export Entra ID hosting integration to polyglot AppHosts - #21361
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21361Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21361" |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the Entra ID polyglot integration changes.
No open issues 🎉
What changed in this PR
Addresses #21076 by exposing the Entra ID hosting integration to polyglot AppHosts while preserving existing C# APIs and preview versioning.
Changes:
- Adds typed exports for registrations, credentials, owners, deferred redirects, and managed-identity federation through the existing generic
withReferencedispatcher. - Adds behavior tests, TypeScript declaration snapshots, and Azure polyglot fixture coverage, with updated test routing.
- Documents TypeScript usage and the distinction between configuration-only references and registrations that retain Azure provisioning setup.
| File | Description |
|---|---|
| tests/PolyglotAppHosts/Aspire.Hosting.Azure/TypeScript/aspire.config.json | Adds the Entra integration to the fixture. |
| tests/PolyglotAppHosts/Aspire.Hosting.Azure/TypeScript/apphost.mts | Exercises Entra exports in TypeScript. |
| tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/EntraIdCodeGenerationTests.Exports_GenerateTypedDeclarationsAndDocumentation.verified.ts | Records generated TypeScript contracts. |
| tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/EntraIdCodeGenerationTests.cs | Checks exported declarations and documentation metadata. |
| tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.csproj | References Entra for code-generation tests. |
| tests/Aspire.Hosting.Azure.EntraId.Tests/Snapshots/EntraIdPolyglotTests.Redirects_KeepEndpointValuesDeferred_operation=Run.verified.bicep | Captures deferred run-mode redirects. |
| tests/Aspire.Hosting.Azure.EntraId.Tests/Snapshots/EntraIdPolyglotTests.Redirects_KeepEndpointValuesDeferred_operation=Publish.verified.bicep | Captures deferred publish-mode redirects. |
| tests/Aspire.Hosting.Azure.EntraId.Tests/Snapshots/EntraIdPolyglotTests.OwnersAndRedirects_PreserveDeferredValuesAndOrder.verified.bicep | Captures owner and redirect composition. |
| tests/Aspire.Hosting.Azure.EntraId.Tests/Snapshots/EntraIdPolyglotTests.Credentials_EmitTypedSettingsAndPreserveSecretReferences_operation=Run.verified.txt | Captures resolved runtime credential settings. |
| tests/Aspire.Hosting.Azure.EntraId.Tests/Snapshots/EntraIdPolyglotTests.Credentials_EmitTypedSettingsAndPreserveSecretReferences_operation=Publish.verified.txt | Captures published settings with deferred secrets. |
| tests/Aspire.Hosting.Azure.EntraId.Tests/EntraIdProvisioningTests.cs | Extends configuration-only deployment coverage to exports. |
| tests/Aspire.Hosting.Azure.EntraId.Tests/EntraIdPolyglotTests.cs | Tests adapters, validation, references, and deferred values. |
| tests/Aspire.Hosting.Azure.EntraId.Tests/Aspire.Hosting.Azure.EntraId.Tests.csproj | Adds capability-scanning test support. |
| src/Aspire.Hosting.Azure.EntraId/README.md | Documents TypeScript examples and configuration semantics. |
| src/Aspire.Hosting.Azure.EntraId/EntraIdResourceExtensions.Polyglot.cs | Adds typed, language-neutral export adapters. |
| src/Aspire.Hosting.Azure.EntraId/EntraIdResourceExtensions.cs | Marks exports and preserves C# overloads. |
| src/Aspire.Hosting.Azure.EntraId/EntraIdApplicationResource.cs | Integrates Entra with generic reference dispatch. |
| src/Aspire.Hosting.Azure.EntraId/Aspire.Hosting.Azure.EntraId.csproj | Enables integration analyzers and removes the polyglot opt-out. |
| eng/github-ci/test-trigger-map.yml | Routes Entra changes to polyglot validation. |
Review effort: Balanced
30cd6e8 to
0392698
Compare
This comment has been minimized.
This comment has been minimized.
Preserve C# APIs while adding typed ATS adapters, generic reference dispatch, credential and deferred value coverage, and TypeScript fixture validation. Co-authored-by: Copilot App <[email protected]>
Add a withAppRole adapter over the new EntraIdAppRole API, with coverage, fixture usage, and README guidance. Co-authored-by: Copilot App <[email protected]>
Add adapters for application ID URIs, scopes, scope URIs, first-party API permissions and consent, plus a reference export that sets the DownstreamApis prefix. Co-authored-by: Copilot App <[email protected]>
0392698 to
6071440
Compare
This comment has been minimized.
This comment has been minimized.
Add Go, Java, Python, and TypeScript PolyglotAppHosts fixtures for the Entra integration, remove the TypeScript-only coverage in the shared Azure fixture and the generated-code snapshot test, and drop the redundant analyzer property. Co-authored-by: Copilot App <[email protected]>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
Undefined numeric enum values are silently treated as application permissions, allowing invalid input to generate app-only role assignments instead of being rejected.
3 open issues
1 file not reviewed
tests/PolyglotAppHosts/Aspire.Hosting.Azure.EntraId/TypeScript/package-lock.json: Generated file
Review effort: Balanced
…overage Port the remaining coverage from the competing Entra polyglot PR: a Rust fixture compiled by the Rust validation runner, selector routing tests for every fixture language, generic withReference dispatch coverage for .NET and non-.NET consumers, and a README overview of polyglot AppHost support. Co-authored-by: Copilot App <[email protected]>
This comment has been minimized.
This comment has been minimized.
The generic fixture-consumer routing test already covers every PolyglotAppHosts fixture. Co-authored-by: Copilot App <[email protected]>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
The generated SDK documentation incorrectly excludes existing registrations and should describe their configuration-only behavior while limiting provisioning claims to registrations created by Aspire.
4 open issues
1 file not reviewed
tests/PolyglotAppHosts/Aspire.Hosting.Azure.EntraId/TypeScript/package-lock.json: Generated file
Review effort: Balanced
Drop the partial class and place each internal export adapter, and the DTO types, in EntraIdResourceExtensions.cs beside the API it adapts. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
Catch-all permission handling accepts undefined numeric types as application permissions, allowing malformed input to silently request app-only access instead of failing validation.
1 open issue
4 resolved since last review
1 file not reviewed
tests/PolyglotAppHosts/Aspire.Hosting.Azure.EntraId/TypeScript/package-lock.json: Generated file
Review effort: Balanced
Reject undefined permission types instead of treating them as application permissions, mark required DTO properties, and document configuration-only existing registrations and non-additive consent in the exported API docs. Co-authored-by: Copilot App <[email protected]>
Tests selector3 / 100 PR test projects · 2 PR jobs, from 31 changed files. Selected PR test projects (3 / 100)
Selected PR jobs (2)
How these were chosen — grouped by what changed🔧 🔧 🔧 📄 📄 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 Job reasons
Selection computed for commit |
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review findings requiring changes to the Entra ID polyglot integration.
No open issues 🎉
1 resolved since last review
1 file not reviewed
tests/PolyglotAppHosts/Aspire.Hosting.Azure.EntraId/TypeScript/package-lock.json: Generated file
Review effort: Balanced
PR Testing ReportPR Information
Artifact Version Verification
Changes Analyzed
Test Scenarios ExecutedScenario 1: TypeScript AppHost for an existing Entra sample appObjective: Replace the C# AppHost of a Microsoft.Identity.Web sample (Blazor web frontend calling a protected API; both stay .NET projects) with a TypeScript Steps:
Observations:
Scenario 2: Deploy the TypeScript AppHost to Azure Container AppsObjective: Deploy the same AppHost and check the published registrations and configuration. Observations:
Findings (none attributed to the PR)
Not covered
Summary
Overall Result✅ PR VERIFIED for the TypeScript AppHost scenario; no defects found in the PR. |
|
Pull request created: #1973
|
|
📝 Documentation has been drafted in microsoft/aspire.dev#1973 targeting Added a new Microsoft Entra ID integration page ( Note This draft PR needs human review before merging. |



Description
Enables polyglot AppHosts to use the Entra ID hosting integration, including new registrations, configuration-only references to existing registrations, consumer settings, all built-in credential kinds, owners, deferred redirect URIs, application roles, API scopes and permissions, admin consent, and managed-identity federation.
Fixes #21076
Supersedes #21292, whose coverage is included here: Rust fixture plus Rust runner compilation, CI routing for every fixture language, and generic
withReferencedispatch coverage.Existing C# signatures and behavior are preserved, as is the package's preview versioning. Overloaded C# APIs remain available; internal ATS adapters expose one typed capability per concept. Entra references use the existing generic
withReferencedispatcher rather than introducing a competing export.addExistingEntraApplicationdoes not enable Azure provisioning or query Graph. FluentasExistingApplicationretains previously enabled Azure setup.withAppRole(value, displayName, description, { allowedMemberTypes, id, isEnabled })over the newEntraIdAppRoleAPI; the generated Bicep matches the C# call.withApplicationIdUri,withScope,getScopeUri,withPreAuthorizedApplication,withApiPermissionsandwithAdminConsentfor registrations in the AppHost, pluswithExternalApiPermissions/withExternalApiAdminConsentfor Microsoft Graph and other APIs (well-known API enum or custom API DTO).withEntraIdReferenceis the only way to set theDownstreamApisprefix, since the genericwithReferencedispatcher has no slot for it.tests/PolyglotAppHosts/Aspire.Hosting.Azure.EntraIdfixtures that exercise every export, updates test routing, and documents TypeScript usage.Examples
Existing C# AppHosts continue to work unchanged:
Generated TypeScript supports mixed ID inputs and typed credential arguments:
New registrations support deferred endpoint redirects and publish-time federation:
Security considerations
This exposes existing identity and credential configuration through ATS; it does not install or configure workload authentication libraries, add scopes/consent, or change authorization behavior. Client secrets and certificate passwords require secret parameters. Existing registrations are never modified. Creating registrations and federation trust still requires the existing Azure/Graph permissions; owners can manage registrations. Certificate and assertion paths identify files on the consumer, not files read by the AppHost.
Validation
The following commands were run on Windows:
dotnet test --project tests\Aspire.Hosting.Azure.EntraId.Tests\Aspire.Hosting.Azure.EntraId.Tests.csproj --no-launch-profile -- --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'dotnet test --project tests\Aspire.Hosting.CodeGeneration.TypeScript.Tests\Aspire.Hosting.CodeGeneration.TypeScript.Tests.csproj --no-launch-profile -- --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'dotnet test --project tests\Infrastructure.Tests\Infrastructure.Tests.csproj --no-launch-profile -- --filter-namespace 'Infrastructure.Tests.TestTriggerMap' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'PrComparisonBaseTestsand access-denied cleanup of temporary Git objects inSelectTestsCliTestsdotnet test --project tests\Infrastructure.Tests\Infrastructure.Tests.csproj --no-launch-profile -- --filter-namespace 'Infrastructure.Tests.TestTriggerMap' --filter-not-class '*.PrComparisonBaseTests' --filter-not-class '*.SelectTestsCliTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'dotnet run --project tools\SelectTests -- --changed-files artifacts\entra-polyglot\changed-files.txt --explaindotnet build src\Aspire.Cli\Aspire.Cli.csproj --nologo -v:q /p:SkipNativeBuild=trueSet-Locationinto a copy of eachtests\PolyglotAppHosts\Aspire.Hosting.Azure.EntraIdfixture (local project mapping), thenaspire restoreandnpm run build/go build ./.../pyright/javac --enable-preview --source 25/cargo checkgit diff --checkManual verification used the locally built CLI (
dotnet .\artifacts\bin\Aspire.Cli\Debug\net11.0\aspire.dll) and a temporary generated TypeScript AppHost:All commands succeeded. Existing registrations reported healthy, and a Node consumer exited successfully after asserting its injected configuration, including secret and certificate password values. Configuration-only publish/deploy completed without Azure provisioning steps. New-registration publish generated Graph application/service-principal Bicep, owners, managed-identity federation, and environment-derived redirect URLs; the templates were inspected. The validation AppHost was stopped.
After rebasing onto main (including #21357), generated TypeScript AppHosts calling
withAppRoleand the scope/permission/consent exports published successfully; the Bicep contained the expectedappRoles, identifier URIs, scopes and pre-authorized clients, and the consumer received the expectedDownstreamApisconfiguration. No live Azure/Graph mutation was performed. Existing NU1903 advisories forSystem.Security.Cryptography.Xmlwere not changed.Checklist
<remarks />and<code />elements on your triple slash comments?