Repository navigation
Add polyglot support for Azure Entra ID hosting - #21292
Sébastien Ros (sebastienros) wants to merge 2 commits into
Conversation
Export Entra configuration through ATS, preserve CLR overloads with focused adapters, and exercise all five polyglot SDKs. Co-authored-by: Copilot App <[email protected]>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21292Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21292" |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🔵 Needs a closer look
The credential and federation exports span five language SDKs and warrant human review given the documented cloud-runtime and Docker/Linux validation limits.
No open issues 🎉
1 file not reviewed
tests/PolyglotAppHosts/Aspire.Hosting.Azure.EntraId/TypeScript/package-lock.json: Generated file
What changed in this PR
Extends the existing Azure Entra ID hosting integration to TypeScript, Python, Go, Java, and Rust AppHosts, building on the federation support from #21227 while preserving existing C# overloads.
Changes:
- Exports Entra configuration APIs, credential factories, federation dispatch, and resource-specific references.
- Adds five-language fixtures and behavioral tests for reference dispatch, credentials, and CI routing.
- Enables polyglot package discovery, adds Rust fixture compilation, and documents usage.
| File | Description |
|---|---|
| tests/PolyglotAppHosts/Aspire.Hosting.Azure.EntraId/TypeScript/tsconfig.json | Configures strict fixture type checking. |
| tests/PolyglotAppHosts/Aspire.Hosting.Azure.EntraId/TypeScript/package.json | Declares TypeScript fixture dependencies. |
| tests/PolyglotAppHosts/Aspire.Hosting.Azure.EntraId/TypeScript/package-lock.json | Locks TypeScript fixture dependencies. |
| tests/PolyglotAppHosts/Aspire.Hosting.Azure.EntraId/TypeScript/aspire.config.json | Selects the TypeScript AppHost and Entra integration. |
| tests/PolyglotAppHosts/Aspire.Hosting.Azure.EntraId/TypeScript/apphost.mts | Exercises exports with a model-only execution option. |
| tests/PolyglotAppHosts/Aspire.Hosting.Azure.EntraId/Rust/Cargo.toml | Defines the Rust fixture and dependencies. |
| tests/PolyglotAppHosts/Aspire.Hosting.Azure.EntraId/Rust/Cargo.lock | Locks Rust fixture dependencies. |
| tests/PolyglotAppHosts/Aspire.Hosting.Azure.EntraId/Rust/aspire.config.json | Enables the Rust AppHost and Entra integration. |
| tests/PolyglotAppHosts/Aspire.Hosting.Azure.EntraId/Rust/apphost.rs | Exercises Entra APIs through the Rust SDK. |
| tests/PolyglotAppHosts/Aspire.Hosting.Azure.EntraId/Python/pylock.apphost.toml | Locks the generated Python SDK dependency. |
| tests/PolyglotAppHosts/Aspire.Hosting.Azure.EntraId/Python/aspire.config.json | Enables the Python AppHost and Entra integration. |
| tests/PolyglotAppHosts/Aspire.Hosting.Azure.EntraId/Python/apphost.py | Exercises Entra APIs through the Python SDK. |
| tests/PolyglotAppHosts/Aspire.Hosting.Azure.EntraId/Python/apphost_requirements.txt | References the generated Python SDK. |
| tests/PolyglotAppHosts/Aspire.Hosting.Azure.EntraId/Java/aspire.config.json | Enables the Java AppHost and Entra integration. |
| tests/PolyglotAppHosts/Aspire.Hosting.Azure.EntraId/Java/AppHost.java | Exercises Entra APIs through the Java SDK. |
| tests/PolyglotAppHosts/Aspire.Hosting.Azure.EntraId/Go/go.mod | References the generated local Go SDK. |
| tests/PolyglotAppHosts/Aspire.Hosting.Azure.EntraId/Go/aspire.config.json | Enables the Go AppHost and Entra integration. |
| tests/PolyglotAppHosts/Aspire.Hosting.Azure.EntraId/Go/apphost.go | Exercises Entra APIs through the Go SDK. |
| tests/Infrastructure.Tests/TestTriggerMap/SelectTestsAcceptanceTests.cs | Tests Entra package and fixture CI routing. |
| tests/Aspire.Hosting.Azure.EntraId.Tests/MicrosoftIdentityWebConfigurationTests.cs | Exercises credential factories in configuration-binding tests. |
| tests/Aspire.Hosting.Azure.EntraId.Tests/EntraIdResourceBuilderTests.cs | Tests reference dispatch, federation targets, and password validation. |
| src/Aspire.Hosting.Azure.EntraId/README.md | Documents polyglot references, overloads, and credentials. |
| src/Aspire.Hosting.Azure.EntraId/EntraIdResourceExtensions.cs | Adds exports, credential factories, and a federation adapter. |
| src/Aspire.Hosting.Azure.EntraId/EntraIdApplicationResource.cs | Adds custom reference dispatch and exports credential handles. |
| src/Aspire.Hosting.Azure.EntraId/Aspire.Hosting.Azure.EntraId.csproj | Removes the polyglot compatibility opt-out. |
| eng/github-ci/test-trigger-map.yml | Routes Entra package changes to polyglot validation. |
| .github/workflows/polyglot-validation/test-rust.sh | Compiles Rust integration fixtures without provisioning. |
Review effort: Balanced
Add targeted ATS XML documentation overrides for credential handles, federation options, parameter variants, redirect URIs, and reference configuration while preserving C# documentation. Co-authored-by: Copilot App <[email protected]>
Tests selector3 / 100 PR test projects · 2 PR jobs, from 26 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.
🔵 Needs a closer look
The authentication surface now spans five generated SDKs, while cloud runtime and Docker/Linux CI validation remain incomplete and warrant human review.
No open issues 🎉
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 verificationInstalled the dogfood CLI into an isolated temporary directory using: curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh |
bash -s -- 21292 --install-path "$testDir/cli" --skip-path --skip-extensionThe installed binary reported Changes analyzed
Test scenarios executed
Fresh project setupCreated a new project for each scenario using the PR's template hive: "$cli" new aspire-ts-empty --name EntraScenario --output "$scenarioDir" \
--source "$testDir/cli/hives/pr-21292/packages" \
--version 17.0.0-pr.21292.ga0058d39 \
--localhost-tld false --suppress-agent-init --non-interactive
"$cli" add Aspire.Hosting.Azure.EntraId --non-interactive
"$cli" add Aspire.Hosting.Azure.AppContainers --non-interactiveThe comprehensive TypeScript test AppHost is preserved as PublishRan in the fresh comprehensive AppHost directory: npx tsc --noEmit
Azure__SubscriptionId="<sebros dev subscription>" \
Azure__Location=westus2 \
Azure__ResourceGroup=rg-entra-pr21292-preview-1792779000 \
Parameters__tenant=contoso.onmicrosoft.com \
Parameters__client=00000000-0000-0000-0000-000000000001 \
Parameters__secret=placeholder-not-a-real-credential \
Parameters__owner=00000000-0000-0000-0000-000000000001 \
Parameters__redirect=https://example.com/signin-oidc \
Parameters__host=example.com \
"$cli" publish --apphost apphost.mts --output-path "$testDir/publish" --non-interactiveThe subscription was resolved read-only from the Azure CLI's existing login context. Verified:
Local runtimeThe local scenario adds only existing registrations and parameter resources; it does not add an Azure deployment environment, ENTRA_TEST=local \
Parameters__tenant=contoso.onmicrosoft.com \
Parameters__client=00000000-0000-0000-0000-000000000001 \
Parameters__secret=placeholder-not-a-real-credential \
"$cli" start --apphost apphost.mts --isolated --format Json --non-interactive
"$cli" wait existing --status up --timeout 60 --apphost apphost.mts --non-interactive
"$cli" wait parameterized --status up --timeout 60 --apphost apphost.mts --non-interactive
"$cli" describe --apphost apphost.mts --format Json --non-interactive
"$cli" stop --apphost apphost.mts --non-interactiveBoth Entra resources reported Negative casesEach fresh scenario ran: ENTRA_TEST="<case>" "$cli" publish --apphost apphost.mts --non-interactive
Harness correctionsThe initial fresh template had no CI infrastructure validationThe changed Rust script is copied into the Rust container and executed by Inspected the actual Rust job log, not just its advisory job conclusion: The new fixture was compiled and the pre-existing Redis runtime scenario still executed. Overall resultPassed for the approved scope: the latest packaged PR TypeScript SDK supports the new methods, Not validated: Azure deployment/Bicep application, real Microsoft Graph permissions, actual registration creation, Artifacts and cleanupThe report, test AppHost, publish artifacts, sanitized structured runtime state, and scenario/CI logs are preserved in the session Library area. |
|
Superseded by #21361 |
## 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 `withReference` dispatch 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 `withReference` dispatcher rather than introducing a competing export. - Tenant and client IDs independently accept literals or parameter resources. - Top-level `addExistingEntraApplication` does not enable Azure provisioning or query Graph. Fluent `asExistingApplication` retains previously enabled Azure setup. - Endpoint redirects remain deferred through run and publish, and secret/password parameters retain secret tracking. - Exports `withAppRole(value, displayName, description, { allowedMemberTypes, id, isEnabled })` over the new `EntraIdAppRole` API; the generated Bicep matches the C# call. - Exports `withApplicationIdUri`, `withScope`, `getScopeUri`, `withPreAuthorizedApplication`, `withApiPermissions` and `withAdminConsent` for registrations in the AppHost, plus `withExternalApiPermissions`/`withExternalApiAdminConsent` for Microsoft Graph and other APIs (well-known API enum or custom API DTO). `withEntraIdReference` is the only way to set the `DownstreamApis` prefix, since the generic `withReference` dispatcher has no slot for it. - Adds behavior and generated TypeScript contract coverage, adds dedicated Go, Java, Python, Rust and TypeScript `tests/PolyglotAppHosts/Aspire.Hosting.Azure.EntraId` fixtures that exercise every export, updates test routing, and documents TypeScript usage. ### Examples Existing C# AppHosts continue to work unchanged: ```csharp var tenantId = builder.AddParameter("entra-tenant"); var clientId = builder.AddParameter("entra-client"); var secret = builder.AddParameter("entra-secret", secret: true); var entra = builder.AddExistingEntraApplication("entra", tenantId, clientId) .WithClientSecret(secret); builder.AddContainer("worker", "my-worker-image") .WithReference(entra, connectionName: "AUTH"); ``` Generated TypeScript supports mixed ID inputs and typed credential arguments: ```typescript const tenantId = await builder.addParameter("entra-tenant"); const secret = await builder.addParameter("entra-secret", { secret: true }); const entra = await builder.addExistingEntraApplication( "entra", tenantId, "00001111-aaaa-2222-bbbb-3333cccc4444") .withClientSecret(secret); await builder.addExecutable("worker", "node", ".", ["worker.mjs"]) .withReference(entra, { connectionName: "AUTH" }); ``` New registrations support deferred endpoint redirects and publish-time federation: ```typescript const entra = await builder.addEntraIdApplication("entra"); const web = await builder.addContainer("web", "my-web-image") .withHttpEndpoint({ targetPort: 8080 }) .withReference(entra); await entra.withRedirectUris(await web.getEndpoint("http"), { callbackPaths: ["/signin-oidc"], }); await entra.publishWithFederatedManagedIdentityCredential({ identity: web }); ``` ### 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: | Command | Result | | --- | --- | | `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'` | Passed, 452 tests | | `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'` | Passed, 153 tests | | `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'` | 314 passed, 22 failed: Windows bash-path failures in `PrComparisonBaseTests` and access-denied cleanup of temporary Git objects in `SelectTestsCliTests` | | `dotnet 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'` | Passed, 255 map, acceptance, and graph tests | | `dotnet run --project tools\SelectTests -- --changed-files artifacts\entra-polyglot\changed-files.txt --explain` | All changed files attributed; selected Entra, Azure, TypeScript codegen, and infrastructure tests plus polyglot/API compatibility jobs | | `dotnet build src\Aspire.Cli\Aspire.Cli.csproj --nologo -v:q /p:SkipNativeBuild=true` | Passed | | `Set-Location` into a copy of each `tests\PolyglotAppHosts\Aspire.Hosting.Azure.EntraId` fixture (local project mapping), then `aspire restore` and `npm run build` / `go build ./...` / `pyright` / `javac --enable-preview --source 25` / `cargo check` | All five passed, mirroring the CI polyglot validation scripts | | `git diff --check` | Passed | Manual verification used the locally built CLI (`dotnet .\artifacts\bin\Aspire.Cli\Debug\net11.0\aspire.dll`) and a temporary generated TypeScript AppHost: ```powershell dotnet .\artifacts\bin\Aspire.Cli\Debug\net11.0\aspire.dll restore --apphost artifacts\entra-polyglot\apphost.mts --non-interactive dotnet .\artifacts\bin\Aspire.Cli\Debug\net11.0\aspire.dll start --non-interactive --isolated --apphost artifacts\entra-polyglot\apphost.mts --format Json dotnet .\artifacts\bin\Aspire.Cli\Debug\net11.0\aspire.dll describe --apphost artifacts\entra-polyglot\apphost.mts --format Json dotnet .\artifacts\bin\Aspire.Cli\Debug\net11.0\aspire.dll logs consumer --apphost artifacts\entra-polyglot\apphost.mts --non-interactive dotnet .\artifacts\bin\Aspire.Cli\Debug\net11.0\aspire.dll stop --apphost artifacts\entra-polyglot\apphost.mts --non-interactive dotnet .\artifacts\bin\Aspire.Cli\Debug\net11.0\aspire.dll publish --apphost artifacts\entra-polyglot\apphost.mts --output-path artifacts\entra-polyglot\publish-existing --non-interactive --include-exception-details dotnet .\artifacts\bin\Aspire.Cli\Debug\net11.0\aspire.dll deploy --apphost artifacts\entra-polyglot\apphost.mts --output-path artifacts\entra-polyglot\deploy-existing --non-interactive --include-exception-details $env:ENTRA_SCENARIO='create' dotnet .\artifacts\bin\Aspire.Cli\Debug\net11.0\aspire.dll publish --apphost artifacts\entra-polyglot\apphost.mts --output-path artifacts\entra-polyglot\publish-created --non-interactive --include-exception-details ``` 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 `withAppRole` and the scope/permission/consent exports published successfully; the Bicep contained the expected `appRoles`, identifier URIs, scopes and pre-authorized clients, and the consumer received the expected `DownstreamApis` configuration. No live Azure/Graph mutation was performed. Existing NU1903 advisories for `System.Security.Cryptography.Xml` were not changed. ## Checklist - Is this feature complete? - [x] Yes. Ready to ship. - [ ] No. Follow-up changes expected. - Are you including unit tests for the changes and scenario tests if relevant? - [x] Yes - [ ] No - Did you add public API? - [x] Yes - If yes, did you have an API Review for it? - [ ] Yes - [x] No - Did you add `<remarks />` and `<code />` elements on your triple slash comments? - [ ] Yes - [x] No - [ ] No - Does the change make any security assumptions or guarantees? - [x] Yes - If yes, have you done a threat model and had a security review? - [ ] Yes - [x] No - [ ] No --------- Co-authored-by: Copilot App <[email protected]>
Description
Enable Entra ID application registrations and authentication configuration in TypeScript, Python, Go, Java, and Rust AppHosts. This is a follow-up to merged #21227, which is already included in the base branch; it does not modify that PR.
Remove the blanket ATS exclusion and export the complete extension-method surface. Literal/parameter and redirect-URI variants have distinct export names. One internal nullable union adapter covers federation for all consumers, a compute resource, or a user-assigned identity, while preserving all existing C# overloads.
Add credential factories for certificate files, signed assertion files, and federated credentials with token exchange overrides. Credentials remain opaque handles and secret passwords remain parameter resources. Implement custom
withReferencedispatch so ordinary references inject Entra configuration, and exposewithEntraIdReferenceexplicitly as well.Add per-integration fixtures for all five languages, including the first Rust integration fixture and compilation in the existing Rust validation runner. Route Entra package changes to polyglot validation; the existing fixture-directory rule covers all new files. Add focused behavioral coverage for dispatch, credentials, and CI routing, not assertions on generated source shape.
User-facing usage
Existing C# AppHosts continue to work unchanged:
TypeScript AppHosts can now use the same configuration:
Validation
Run from the repository root unless a fixture-directory change is shown.
Passed: both builds, including export analyzers, with zero warnings and errors:
Passed: SDK generation for all five fixtures with the source CLI and local project references:
Passed: TypeScript compilation with both checkers:
cd tests/PolyglotAppHosts/Aspire.Hosting.Azure.EntraId/TypeScript npx tsc --noEmit npx --yes @typescript/native-preview --noEmit --project tsconfig.jsonPassed: Python type checking (zero errors/warnings), plus compilation of the AppHost and generated SDK:
Passed: Go, Java 25, and Rust compilation:
Passed: 14 Entra behavior cases and 6 CI routing cases:
The Entra test restore reported existing NU1902/NU1903 advisories for its Microsoft.Identity.Web transitive cryptography dependencies; this PR does not change those dependencies.
Passed: live TypeScript-to-ATS execution of the fixture, including credential handles, references, and all federation argument variants, without calling
build().run(). The CLI log recordedEntra ID model configured without provisioning.and exit code 0:Passed:
bash -n .github/workflows/polyglot-validation/test-rust.shandgit diff --check.No cloud deployment was run and no Azure/Entra objects were created. Graph provisioning, managed identity token exchange, certificate retrieval, and deployed workload authentication remain unvalidated. Local SDK compilation and model-only execution do not establish cloud runtime compatibility. Docker/Linux CI and the Rust runner's existing Redis runtime scenario were not run locally; the Rust CI job retains its existing advisory status.
Security considerations
The new ATS surface exposes existing Entra credential and federation configuration to trusted AppHost code. It delegates to existing validation and provisioning behavior, keeps certificate passwords in secret parameters, and does not add default trust, bypass existing-registration restrictions, or configure workload authentication middleware.
Fixes: N/A (no linked issue; follows merged #21227).
Checklist
<remarks />and<code />elements on your triple slash comments?