Skip to content

Expose Entra Graph provisioning models for ConfigureInfrastructure - #21724

Merged
Eric Erhardt (eerhardt) merged 1 commit into
mainfrom
eerhardt-entra-provisioning-customization
Nov 3, 2026
Merged

Eric Erhardt (eerhardt) merged 1 commit into
mainfrom
eerhardt-entra-provisioning-customization

Conversation

@eerhardt

Copy link
Copy Markdown
Member

Description

AddEntraIdApplication is an AzureProvisioningResource, so ConfigureInfrastructure can customize its generated Bicep, but the Microsoft Graph provisioning models it builds were internal. Callers couldn't reach them, for example to add application tags or set serviceManagementReference. This makes those models public for C# and exposes them to polyglot AppHosts.

Microsoft Graph tags are a string array, not Azure key/value tags, and serviceManagementReference is a separate string property, so the change exposes those schema-backed properties rather than adding a dedicated API.

User-facing usage

C# AppHost:

using Aspire.Hosting.Azure.EntraId.Provisioning;

var entra = builder.AddEntraIdApplication("entra")
    .ConfigureInfrastructure(infrastructure =>
    {
        var application = infrastructure.GetProvisionableResources()
            .OfType<MicrosoftGraphApplication>()
            .Single(r => r.BicepIdentifier == "application");
        application.Tags.Add("department:engineering");
        application.ServiceManagementReference = "your-service-management-reference";

        var principal = infrastructure.GetProvisionableResources()
            .OfType<MicrosoftGraphServicePrincipal>().Single();
        principal.Tags.Add("department:engineering");
    });

TypeScript AppHost, with the new experimental Aspire.Hosting.Azure.Provisioning.EntraId package:

const serviceReference = await builder.addParameter("service-reference");
const entra = await builder.addEntraIdApplication("entra");
await entra.configureInfrastructure(async infrastructure => {
    const application = await infrastructure.getMicrosoftGraphApplicationByIdentifier("application");
    const tags = await application.tags.get();
    await tags.add("department:engineering");
    await application.serviceManagementReference.set(infrastructure.bicep().parameter(serviceReference));

    const principal = await infrastructure.getMicrosoftGraphServicePrincipalByIdentifier("servicePrincipal");
    const principalTags = await principal.tags.get();
    await principalTags.add("department:engineering");
});

What changed

  • The Graph provisioning models in Aspire.Hosting.Azure.EntraId.Provisioning are public and documented: application, service principal, federated credential, permission grants, and the nested scope, role, and credential types. FederatedIdentityCredential is renamed MicrosoftGraphFederatedIdentityCredential to match the others and avoid colliding with the Azure.Provisioning type of the same name.
  • New schema-backed properties: Tags, ServiceManagementReference, Description, Notes, GroupMembershipClaims, IsFallbackPublicClient, HomePageUrl, LogoutUrl, EnableAccessTokenIssuance, SpaRedirectUris and PublicClientRedirectUris on the application, and AccountEnabled, AppRoleAssignmentRequired, Description, Notes and NotificationEmailAddresses on the service principal. Unset properties emit nothing, so existing templates are unchanged.
  • New Aspire.Hosting.Azure.Provisioning.EntraId package, following the existing Key Vault and Storage provisioning overlays. It projects the models through the shared proxy generator and Bicep expression runtime, and is experimental like the others.
  • READMEs document the C# and TypeScript usage. The TypeScript fixture uses the package, and the Go, Java and Python Entra fixtures reference it like the Storage and Key Vault fixtures.
  • Generated api/*.cs baselines are untouched.

Things to know

  • An API registration that uses the default api://{clientId} URI is emitted as two Microsoft.Graph/applications declarations. The second repeats DisplayName and UniqueName, so changing them on only the first is not enough. This is existing behavior and is documented in the XML remarks. It is a workaround for msgraph-bicep-types#239; the code comment now links it.
  • Customization applies to registrations Aspire creates. References to existing registrations aren't provisioned or modified.

Validation

  • 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, 658 tests. The new tests cover C# customization and the exported ATS proxies; snapshots are generated Bicep.
  • The generated customization Bicep builds with az bicep build against the pinned Graph extension.
  • Generated TypeScript SDK: the Entra TypeScript fixture type-checks (npm run build). The generated Go SDK builds and the Python SDK compiles. Java and Rust output generated without error but was not compiled.
  • Not run: deployment E2E tests and a real deployment, and the SDKs were not regenerated or compiled after the final properties were added.
  • Infrastructure.Tests test-selection tests for the map and graph passed. The broader selector namespace has unrelated Windows failures: Bash receives unquoted Windows paths and git fixture cleanup is denied.

Relates to #21060

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

Make the Microsoft Graph Azure.Provisioning models public so C# callers can
customize the generated Entra application and service principal, for example
tags and serviceManagementReference. Add common application and service
principal properties, rename FederatedIdentityCredential to
MicrosoftGraphFederatedIdentityCredential for consistency, and add the opt-in
Aspire.Hosting.Azure.Provisioning.EntraId package that projects the models to
polyglot AppHosts through the shared provisioning proxy generator.

Co-authored-by: Copilot App <[email protected]>
@github-actions github-actions Bot added the area-integrations Issues pertaining to Aspire Integrations packages label Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21724

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21724"

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Tests selector

Selects the full PR test matrix + all PR-gated jobs (ALL) — a rule matching 'Aspire.slnx' selects ALL


Selection computed for commit 95c6ec0.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Deployment E2E coverage does not verify custom application tags and serviceManagementReference through Graph after deployment and redeployment, or preservation of the required service-principal tag, leaving provider rejection or value loss undetected.

1 open issue
What changed in this PR

Exposes Microsoft Graph provisioning models so C# and polyglot AppHosts can customize Entra registrations through ConfigureInfrastructure, addressing the customization work tracked in #21060.

Changes:

  • Makes Graph models public and documented, with additional application and service-principal properties.
  • Adds an experimental Entra provisioning package for polyglot customization.
  • Adds customization tests, Bicep snapshots, fixture references, and usage documentation.
File Description
tests/​PolyglotAppHosts/​Aspire.Hosting.Azure.EntraId/​TypeScript/​aspire.config.json References the new provisioning package.
tests/​PolyglotAppHosts/​Aspire.Hosting.Azure.EntraId/​TypeScript/​apphost.mts Exercises Graph metadata customization.
tests/​PolyglotAppHosts/​Aspire.Hosting.Azure.EntraId/​Python/​aspire.config.json References the new provisioning package.
tests/​PolyglotAppHosts/​Aspire.Hosting.Azure.EntraId/​Java/​aspire.config.json References the new provisioning package.
tests/​PolyglotAppHosts/​Aspire.Hosting.Azure.EntraId/​Go/​aspire.config.json References the new provisioning package.
tests/​Aspire.Hosting.Azure.EntraId.Tests/​Snapshots/​EntraIdProvisioningTests.ConfigureInfrastructure_CustomizesApplicationMetadata.verified.bicep Records C# customization output.
tests/​Aspire.Hosting.Azure.EntraId.Tests/​Snapshots/​EntraIdPolyglotTests.ConfigureInfrastructure_ProxiesCustomizeGraphResources.verified.bicep Records proxy customization output.
tests/​Aspire.Hosting.Azure.EntraId.Tests/​EntraIdProvisioningTests.cs Tests C# customization and parameter binding.
tests/​Aspire.Hosting.Azure.EntraId.Tests/​EntraIdPolyglotTests.cs Tests exported proxies and Bicep expressions.
tests/​Aspire.Hosting.Azure.EntraId.Tests/​Aspire.Hosting.Azure.EntraId.Tests.csproj Adds the provisioning package test reference.
src/​Aspire.Hosting.Azure.Provisioning/​README.md Lists Entra provisioning support.
src/​Aspire.Hosting.Azure.Provisioning.EntraId/​README.md Documents installation and TypeScript usage.
src/​Aspire.Hosting.Azure.Provisioning.EntraId/​AtsTypeMappings.cs Registers Graph models for proxy generation.
src/​Aspire.Hosting.Azure.Provisioning.EntraId/​Aspire.Hosting.Azure.Provisioning.EntraId.csproj Defines the experimental provisioning package.
src/​Aspire.Hosting.Azure.EntraId/​README.md Documents C# and TypeScript customization.
src/​Aspire.Hosting.Azure.EntraId/​Provisioning/​MicrosoftGraphServicePrincipal.cs Exposes models and adds service-principal properties.
src/​Aspire.Hosting.Azure.EntraId/​Provisioning/​MicrosoftGraphPermissionGrants.cs Exposes and documents permission-grant models.
src/​Aspire.Hosting.Azure.EntraId/​Provisioning/​MicrosoftGraphKeyCredential.cs Exposes and documents certificate credentials.
src/​Aspire.Hosting.Azure.EntraId/​Provisioning/​MicrosoftGraphFederatedIdentityCredential.cs Renames, exposes, and documents federated credentials.
src/​Aspire.Hosting.Azure.EntraId/​Provisioning/​MicrosoftGraphAppRole.cs Exposes and documents application roles.
src/​Aspire.Hosting.Azure.EntraId/​Provisioning/​MicrosoftGraphApplication.cs Exposes the application model and adds schema-backed properties.
src/​Aspire.Hosting.Azure.EntraId/​Provisioning/​MicrosoftGraphApiConstructs.cs Exposes and documents nested permission models.
src/​Aspire.Hosting.Azure.EntraId/​Provisioning/​EntraIdApiProvisioning.cs Adds explanatory links to the existing workaround comment.
src/​Aspire.Hosting.Azure.EntraId/​EntraIdApplicationResource.cs Uses the renamed federated credential model.
Aspire.slnx Includes the new provisioning project.

Review effort: Balanced

@IEvangelist

Copy link
Copy Markdown
Member

PR Testing Report

PR Information

  • PR: microsoft/aspire#21724
  • Title: Expose Entra Graph provisioning models for ConfigureInfrastructure
  • Head commit: 95c6ec0ca2f1973e99e2d3b7201d682342a21729
  • Tested: 2026-11-03, Windows x64, local isolated AppHosts
  • Live state: Open; head rechecked after execution and unchanged.

Artifact Version Verification

Changes Analyzed

The 25 changed files expose Graph provisioning models, add application/service-principal properties, rename the federated credential model, add the experimental polyglot provisioning overlay, update documentation, and add tests and polyglot fixture references.

  • Hosting/provisioning changes: Yes.
  • Tests and fixture changes: Yes.
  • CLI, dashboard, template, client integration, extension, and CI implementation changes: No.
  • Test-selection impact: The new package is referenced by the Entra test project. Existing Aspire.Hosting.Azure.Provisioning* project rules select the polyglot job, and tests/PolyglotAppHosts/** already selects that job for the changed fixture files. No selector/workflow changes were made or executed as part of this test.

Commands and Environment

The following variables describe the exact paths used:

$base = 'C:\Users\dapine\.copilot\session-state\9e09f226-e30a-4231-9c45-420bee71add6\files'
$root = "$base\pr-21724-test"
$cli = "$root\dogfood\pr-21724\bin\aspire.exe"
$hive = "$root\hives\pr-21724\packages"
$version = '17.0.0-pr.21724.g95c6ec0c'

The installer was invoked from the PR dogfood instructions, with isolation flags:

iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21724 -InstallPath $root -SkipExtension -SkipPath"
& $cli --version

Both succeeded. User profiles and PATH were not modified.

Test Scenarios Executed

1. Source build and Entra regression tests

Status: Passed, 658 succeeded, 0 failed, 0 skipped.

.\restore.cmd
$env:MSBUILDTERMINALLOGGER = 'false'
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"

Restore succeeded with 12 NuGet vulnerability warnings. Test execution succeeded in approximately 23 seconds after the build.

This includes the new C# customization and ATS-proxy Bicep snapshot tests and existing registration, permission, federation, credential, validation, and default-output tests. Expected failure-path logging appears in the log; the runner's actual summary reports zero failed tests.

Evidence: entra-tests.log, restore.log. A final git diff --exit-code and git status --short confirmed no snapshot changes or other repository modifications.

2. Fresh C# AppHost consumes the PR package

Coverage: Happy path and boundaries. Status: Passed.

& $cli new aspire-empty --name EntraCSharp --output "$root\EntraCSharp" --source $hive --version $version --language CSharp --localhost-tld false --suppress-agent-init --use-config-source false --non-interactive
& $cli add Aspire.Hosting.Azure.EntraId --apphost "$root\EntraCSharp\apphost.cs" --version $version --source $hive --non-interactive
$env:ENTRA_TEST_OUTPUT = "$root\csharp-customized.bicep"
& $cli publish --apphost "$root\EntraCSharp\apphost.cs" --output-path "$root\csharp-output" --non-interactive --include-exception-details

All commands exited 0. The temporary AppHost exercised every new application/service-principal property, plus ID-token issuance, using literals and a Bicep parameter. It also checked:

  • Reading unset application tags, notes, public-client redirects, and access-token issuance does not change baseline output.
  • Repeated customized template generation produces exactly the same output. Both boundary checks regenerate via GetBicepTemplateFile, rather than merely reading the cached template string.
  • Explicit false values are emitted for fallback public client, access-token issuance, and service-principal account enabled.
  • Adding service-principal tags preserves WindowsAzureActiveDirectoryIntegratedApp.
  • A scoped API retains the two-application-declaration structure and parameter wiring.

Evidence: new-csharp.log, add-csharp.log, publish-csharp.log, csharp-customized.bicep, csharp-output, and source\apphost.cs.

The publish pipeline's "No azure compute environments found" warning is expected: this app contains only registration resources and intentionally does not deploy compute.

3. Fresh TypeScript AppHost executes generated provisioning APIs

Coverage: Happy path, real generated SDK and RPC callbacks. Status: Passed.

& $cli new aspire-ts-empty --name EntraTypeScript --output "$root\EntraTypeScript" --source $hive --version $version --localhost-tld false --suppress-agent-init --use-config-source false --non-interactive
& $cli add Aspire.Hosting.Azure.Provisioning.EntraId --apphost "$root\EntraTypeScript\apphost.mts" --version $version --source $hive --non-interactive
& $cli publish --apphost "$root\EntraTypeScript\apphost.mts" --output-path "$root\typescript-output" --non-interactive --include-exception-details
Push-Location "$root\EntraTypeScript"
npm run build
Pop-Location

All commands exited 0. npm run build ran ESLint and tsc -p tsconfig.apphost.json successfully.

The AppHost looked up Graph resources by identifier and exercised every new application/service-principal property through generated proxies, including list access, adding both literal and parameter tags, nested redirect collections, notification addresses, and boolean setters.

The C# and TypeScript customized modules were compared in full and are byte-for-byte identical, not merely checked for selected substrings.

Evidence: new-typescript.log, add-typescript.log, publish-typescript.log, typescript-build.log, output-comparison.log, typescript-output, and source\apphost.mts.

4. Generated Bicep compiles against the pinned Graph extension

Status: Passed for both C# and TypeScript modules.

az bicep version
az bicep build --file "$root\csharp-output\customized\customized.bicep"
az bicep build --file "$root\typescript-output\customized\customized.bicep"

Bicep version: 0.41.2 (3e403ea7c1). Both build commands exited 0 against br:mcr.microsoft.com/bicep/extensions/microsoftgraph/v1.0:1.0.0. Only a newer-Bicep-version advisory was printed; no schema or compilation errors.

Evidence: bicep-csharp.log, bicep-typescript.log, and compiled JSON beside each Bicep module.

5. Missing and wrong-type Graph identifiers fail safely

Coverage: Negative. Status: Passed for nonzero failure behavior; diagnostic quality is limited.

foreach ($lookup in @('missing', 'servicePrincipal')) {
    $env:TEST_LOOKUP = $lookup
    & $cli publish --apphost "$root\EntraTypeScript\apphost.mts" --output-path "$root\negative-$lookup" --non-interactive --include-exception-details
}

The app passes the environment value to getMicrosoftGraphApplicationByIdentifier. Both an unknown identifier and an identifier belonging to a service principal exited 6, rather than producing a successful deployment output.

The error identifies the failing capability, but uses the generic message:

getMicrosoftGraphApplicationByIdentifier: Sequence contains no matching element
Code: INTERNAL_ERROR

This is not a good actionable "resource not found" message. It is reported as a diagnostic limitation rather than a new PR-specific correctness failure: this overlay uses the shared provisioning lookup generator.

Evidence: negative-missing.log, negative-servicePrincipal.log, and retained CLI logs.

Summary

Scenario Result Evidence
Entra source regression suite Passed 658/658 tests
Fresh C# package consumption and customization Passed Published modules; unset/idempotence guards
Fresh TypeScript generated SDK and callback execution Passed Publish, ESLint, TypeScript compile
Cross-language output equivalence Passed Byte-for-byte identical customized Bicep
Graph schema compilation Passed Both az bicep build commands exited 0
Missing/wrong-type identifier Safe failure Exit 6 for both; generic diagnostic

Overall Result

Passed within the tested scope. No PR-specific functional failure found.

Not validated: real Entra tenant deployment, deployed token/sign-in behavior, resource startup/dashboard behavior, Linux/container behavior, or Go/Java/Python generated SDK compilation. No tenant objects were created or modified. Publish validates generation, not Microsoft Graph deployment semantics.

The new properties were tested end-to-end from both C# and TypeScript using the final PR artifacts. Source checkout and PR head remained unchanged.

Artifacts and Cleanup

Persistent evidence directory:

C:\Users\dapine\.copilot\session-state\9e09f226-e30a-4231-9c45-420bee71add6\files\pr-21724-evidence

Logs, generated Bicep/JSON, and temporary AppHost source were copied there before cleanup. No screenshots were needed for this infrastructure-generation-only scenario.

The isolated CLI, downloaded hive, and generated project workspace were removed after preserving evidence. Retained evidence and this report are outside that disposable workspace. No surviving processes referenced the test workspace before cleanup.

PR Comment Status

The user explicitly approved posting this report as a PR comment.

@IEvangelist David Pine (IEvangelist) 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.

Reviewed the current diff; no outstanding findings from my review.

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Pull request created: #2043

Generated by PR Documentation Check · copilot · auto · 25.8 AIC · ⌖ 1.18 AIC · ⊞ 7.4K

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

📝 Documentation has been drafted in microsoft/aspire.dev#2043 targeting release/17.0.

Updated customize-resources.mdx: added the Aspire.Hosting.Azure.Provisioning.EntraId package to the provisioning table and a new section on customizing Entra ID applications (C#/TypeScript). Signals: new_public_type (MicrosoftGraphApplication etc.), new_package_added/new_hosting_integration_project (Provisioning.EntraId csproj), integration_readme_changed (EntraId READMEs), pr_body_has_user_facing_section.

Note

This draft PR needs human review before merging.

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

Labels

area-integrations Issues pertaining to Aspire Integrations packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants