Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 20, 2025

Summary

This PR updates the Aspire documentation to reflect the new polyglot-friendly environment variables introduced in dotnet/aspire#12141. This addresses issue #5308.

What Changed

Starting in Aspire 13.0, when using WithReference to connect services, Aspire now injects two types of environment variables to support both .NET and non-.NET workloads:

1. Simplified Format (New)

var apiservice = builder.AddProject<Projects.ApiService>("apiservice");
var frontend = builder.AddProject<Projects.Frontend>("frontend")
    .WithReference(apiservice);

This now generates simplified environment variables that are easier to use from non-.NET languages:

  • APISERVICE_HTTP=http://localhost:5455
  • APISERVICE_HTTPS=https://localhost:7356

Pattern: {RESOURCENAME}_{ENDPOINTNAME} in uppercase

2. .NET Service Discovery Format (Existing)

The existing .NET service discovery format continues to work for backward compatibility:

  • services__apiservice__http__0=http://localhost:5455
  • services__apiservice__https__0=https://localhost:7356

Pattern: services__{servicename}__{endpointname}__{index} in lowercase

Both formats are injected automatically, so existing .NET applications continue to work unchanged, while new polyglot scenarios can use the simpler format.

Custom Environment Variables

For specific endpoint references, developers can use WithEnvironment with GetEndpoint:

var projectA = builder.AddProject<Projects.ProjectA>("projecta");
var projectB = builder.AddProject<Projects.ProjectB>("projectb")
    .WithEnvironment("PROJECTA_URL", projectA.GetEndpoint("https"));

This generates a single custom environment variable: PROJECTA_URL=https://localhost:7356

Files Updated

  • docs/fundamentals/app-host-overview.md - Added comprehensive documentation for both environment variable formats with clear guidance on when to use each
  • docs/get-started/build-aspire-apps-with-nodejs.md - Updated Node.js examples to reference the simplified format (WEATHERAPI_HTTP)
  • docs/deployment/manifest-format.md - Updated manifest JSON examples to show both formats
  • docs/deployment/azd/aca-deployment-azd-in-depth.md - Updated Azure Container Apps Bicep template examples
  • docs/fundamentals/orchestrate-resources.md - Updated external service example
  • docs/extensibility/dev-tunnels-integration.md - Updated dev tunnel example

Impact

These documentation updates:

  • Help developers understand the new simplified environment variable format for polyglot scenarios
  • Maintain clarity about backward compatibility with existing .NET service discovery
  • Provide clear examples for both Node.js/JavaScript and .NET workloads
  • Update deployment manifest and Azure examples to reflect the new reality

Fixes #5308

Original prompt

Please address issue @dotnet/docs-aspire/issues/5308 - taking into account related PR: @dotnet/aspire/pull/12141 ... content related to these changes should be updated accordingly.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Update content based on issue 5308 and related PR 12141 Update documentation for new polyglot environment variables (issue #5308) Oct 20, 2025
@Copilot Copilot AI requested a review from IEvangelist October 20, 2025 15:53
Copilot finished work on behalf of IEvangelist October 20, 2025 15:53
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