Skip to content

Unify ATS withEnvironment exports#15649

Open
sebastienros wants to merge 5 commits intomainfrom
sebros/abstract-ats-withenvironment
Open

Unify ATS withEnvironment exports#15649
sebastienros wants to merge 5 commits intomainfrom
sebros/abstract-ats-withenvironment

Conversation

@sebastienros
Copy link
Copy Markdown
Contributor

Description

Unifies ATS WithEnvironment exports so polyglot apphosts use a single withEnvironment(name, value) API, following the same abstraction pattern used for withReference.

This removes the specialized ATS export names for environment values, keeps the existing runtime C# overloads intact, updates the TypeScript generator and snapshots, and refreshes the checked-in ATS capability baselines.

Validation:

  • ./dotnet.sh test tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.csproj -- --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"
  • ./dotnet.sh test tests/Aspire.Hosting.Azure.Tests/Aspire.Hosting.Azure.Tests.csproj -- --filter-method "*.WithEnvironment_AddsKeyVaultSecretReference" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"

Fixes # (issue)

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
  • Does the change require an update in our Aspire docs?

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 27, 2026

🚀 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 -- 15649

Or

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

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sebastienros sebastienros marked this pull request as ready for review March 27, 2026 19:16
Copilot AI review requested due to automatic review settings March 27, 2026 19:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR unifies Aspire Type System (ATS) environment-variable exports across polyglot app hosts by consolidating multiple specialized WithEnvironment* capability exports into a single withEnvironment(name, value) capability that accepts a broader set of value types.

Changes:

  • Introduces an internal withEnvironment dispatcher export that accepts a union of supported environment value types (string, expressions, endpoint refs, parameters, connection strings, value providers).
  • Removes specialized ATS exports (and generated polyglot APIs) like withEnvironmentExpression, withEnvironmentEndpoint, withEnvironmentParameter, etc., updating TypeScript/Python codegen snapshots and ATS baselines accordingly.
  • Adds support types/interfaces for dispatching custom environment behavior and exports IValueProvider / IManifestExpressionProvider into ATS.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts Snapshot updates reflecting unified TS withEnvironment union-typed API and removal of specialized methods.
tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/HostingContainerResourceCapabilities.verified.txt Removes specialized environment capability entries from TS capability baseline snapshot.
tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py Snapshot updates reflecting unified Python with_env union typing and removal of specialized methods/options.
src/Aspire.Hosting/api/Aspire.Hosting.Capabilities.txt ATS baseline updated: withEnvironment now takes a union of supported types; specialized exports removed.
src/Aspire.Hosting/ResourceBuilderExtensions.cs Adds internal dispatcher export, value-provider wiring, and reflection-based custom dispatch mechanism.
src/Aspire.Hosting/ApplicationModel/IValueWithCustomWithEnvironment.cs Introduces a new experimental interface for value-specific WithEnvironment dispatch behavior.
src/Aspire.Hosting/ApplicationModel/IValueProvider.cs Exports IValueProvider into ATS.
src/Aspire.Hosting/ApplicationModel/IManifestExpressionProvider.cs Exports IManifestExpressionProvider into ATS.
src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs Updates TS generator to emit proper TS unions for ATS union parameters.
src/Aspire.Hosting.Azure/AzureBicepResourceExtensions.cs Stops exporting Azure-specific withEnvironmentFrom* ATS methods; routes through unified environment API.
src/Aspire.Hosting.Azure/AzureBicepResource.cs Makes BicepOutputReference provide custom WithEnvironment dispatch.
src/Aspire.Hosting.Azure.KeyVault/AzureKeyVaultSecretResource.cs Adds custom WithEnvironment dispatch for Key Vault secret resource values.
src/Aspire.Hosting.Azure.KeyVault/AzureKeyVaultSecretReference.cs Adds custom WithEnvironment dispatch for Key Vault secret references.
src/Aspire.Hosting.SqlServer/api/Aspire.Hosting.SqlServer.ats.txt Refreshes checked-in ATS baseline for SqlServer package to match new shared capability set.
playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/apphost.ts Updates playground usage to call unified withEnvironment for endpoint/parameter/connection-string values.
playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/apphost.ts Updates playground usage to call unified withEnvironment for Bicep output & Key Vault secret values.
playground/polyglot/Python/Aspire.Hosting/ValidationAppHost/apphost.py Updates playground usage to call unified with_environment for endpoint/parameter/connection-string values.
playground/polyglot/Python/Aspire.Hosting.Azure/ValidationAppHost/apphost.py Updates playground usage to call unified with_environment for Bicep output & Key Vault secret values.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
sebastienros and others added 2 commits March 27, 2026 13:26
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

🎬 CLI E2E Test Recordings — 52 recordings uploaded (commit a720800)

View recordings
Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
Banner_NotDisplayedWithNoLogoFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJavaEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateJavaAppHostWithViteApp ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RunWithMissingAwaitShowsHelpfulError ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
TypeScriptAppHostWithProjectReferenceIntegration ▶️ View Recording

📹 Recordings uploaded automatically from CI run #23667050573

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants