From 88c80f4b7b758278688139445eda812a80d78eca Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Oct 2025 12:05:19 +0000 Subject: [PATCH 1/2] Initial plan From 396d16dd79a1e9e518973b394c25c99df5d8b84e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Oct 2025 12:14:58 +0000 Subject: [PATCH 2/2] Update environment variable format to polyglot-friendly pattern Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com> --- docs/deployment/azd/aca-deployment-azd-in-depth.md | 4 ++-- docs/deployment/manifest-format.md | 8 ++++---- docs/extensibility/dev-tunnels-integration.md | 2 +- docs/fundamentals/app-host-overview.md | 14 +++++++------- docs/fundamentals/orchestrate-resources.md | 2 +- docs/get-started/build-aspire-apps-with-nodejs.md | 4 ++-- .../testing/mstest/AspireApp.Tests/EnvVarTests.cs | 2 +- .../testing/nunit/AspireApp.Tests/EnvVarTests.cs | 2 +- .../testing/xunit/AspireApp.Tests/EnvVarTests.cs | 2 +- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/docs/deployment/azd/aca-deployment-azd-in-depth.md b/docs/deployment/azd/aca-deployment-azd-in-depth.md index 777a532241..442e9d66fb 100644 --- a/docs/deployment/azd/aca-deployment-azd-in-depth.md +++ b/docs/deployment/azd/aca-deployment-azd-in-depth.md @@ -370,9 +370,9 @@ properties: value: "true" - name: OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES value: "true" - - name: services__apiservice__0 + - name: APISERVICE_HTTP value: http://apiservice.internal.{{ .Env.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN }} - - name: services__apiservice__1 + - name: APISERVICE_HTTPS value: https://apiservice.internal.{{ .Env.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN }} tags: azd-service-name: webfrontend diff --git a/docs/deployment/manifest-format.md b/docs/deployment/manifest-format.md index 6fc40d16fc..05874ef839 100644 --- a/docs/deployment/manifest-format.md +++ b/docs/deployment/manifest-format.md @@ -110,8 +110,8 @@ Publishing the manifest from the default starter template for Aspire produces th "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true", "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true", "ConnectionStrings__cache": "{cache.connectionString}", - "services__apiservice__0": "{apiservice.bindings.http.url}", - "services__apiservice__1": "{apiservice.bindings.https.url}" + "APISERVICE_HTTP": "{apiservice.bindings.http.url}", + "APISERVICE_HTTPS": "{apiservice.bindings.https.url}" }, "bindings": { "http": { @@ -142,8 +142,8 @@ This dependency is known because the environment variables for the _webfrontend_ "env": { // ... other environment variables omitted for clarity "ConnectionStrings__cache": "{cache.connectionString}", - "services__apiservice__0": "{apiservice.bindings.http.url}", - "services__apiservice__1": "{apiservice.bindings.https.url}" + "APISERVICE_HTTP": "{apiservice.bindings.http.url}", + "APISERVICE_HTTPS": "{apiservice.bindings.https.url}" }, ``` diff --git a/docs/extensibility/dev-tunnels-integration.md b/docs/extensibility/dev-tunnels-integration.md index 76ba0fbd2d..6697499bcd 100644 --- a/docs/extensibility/dev-tunnels-integration.md +++ b/docs/extensibility/dev-tunnels-integration.md @@ -101,7 +101,7 @@ The preceding code: When another resource references a dev tunnel, environment variables are injected using the [Aspire service discovery](../service-discovery/overview.md) configuration format. Use the `WithReference` overloads that accept the `IResourceBuilder` parameter to reference a dev tunnel. This injects environment variables like: ```env -services__web__https__0=https://myweb-1234.westeurope.devtunnels.ms/ +WEB_HTTPS=https://myweb-1234.westeurope.devtunnels.ms/ ``` This lets downstream resources use the tunneled address exactly like any other Aspire service discovery entry. diff --git a/docs/fundamentals/app-host-overview.md b/docs/fundamentals/app-host-overview.md index 660e46470f..4ae3b3c42f 100644 --- a/docs/fundamentals/app-host-overview.md +++ b/docs/fundamentals/app-host-overview.md @@ -176,7 +176,7 @@ Project-to-project references are handled differently than resources that have w | Method | Environment variable | |--|--| | `WithReference(cache)` | `ConnectionStrings__cache="localhost:62354"` | -| `WithReference(apiservice)` | `services__apiservice__http__0="http://localhost:5455"`
`services__apiservice__https__0="https://localhost:7356"` | +| `WithReference(apiservice)` | `APISERVICE_HTTP="http://localhost:5455"`
`APISERVICE_HTTPS="https://localhost:7356"` | Adding a reference to the "apiservice" project results in service discovery environment variables being added to the frontend. This is because typically, project-to-project communication occurs over HTTP/gRPC. For more information, see [Aspire service discovery](../service-discovery/overview.md). @@ -202,7 +202,7 @@ var apiservice = builder.AddProject("apiservice") | Method | Environment variable | |---------------------------|-------------------------------------------------------| -| `WithReference(endpoint)` | `services__myapp__endpoint__0=https://localhost:9043` | +| `WithReference(endpoint)` | `MYAPP_ENDPOINT=https://localhost:9043` | The `port` parameter is the port that the container is listening on. For more information on container ports, see [Container ports](networking-overview.md#container-ports). For more information on service discovery, see [Aspire service discovery](../service-discovery/overview.md). @@ -210,20 +210,20 @@ The `port` parameter is the port that the container is listening on. For more in In the preceding section, the method is used to express dependencies between resources. When service endpoints result in environment variables being injected into the dependent resource, the format might not be obvious. This section provides details on this format. -When one resource depends on another resource, the AppHost injects environment variables into the dependent resource. These environment variables configure the dependent resource to connect to the resource it depends on. The format of the environment variables is specific to Aspire and expresses service endpoints in a way that is compatible with [Service Discovery](../service-discovery/overview.md). +When one resource depends on another resource, the AppHost injects environment variables into the dependent resource. These environment variables configure the dependent resource to connect to the resource it depends on. The format of the environment variables is specific to Aspire and expresses service endpoints in a way that is compatible with [Service Discovery](../service-discovery/overview.md) and polyglot scenarios. -Service endpoint environment variable names are prefixed with `services__` (double underscore), then the service name, the endpoint name, and finally the index. The index supports multiple endpoints for a single service, starting with `0` for the first endpoint and incrementing for each endpoint. +Service endpoint environment variable names follow the pattern `{RESOURCENAME}_{ENDPOINTNAME}`, where both the resource name and endpoint name are uppercased. This format is language-agnostic and works well with non-.NET technologies. Consider the following environment variable examples: ```Environment -services__apiservice__http__0 +APISERVICE_HTTP ``` -The preceding environment variable expresses the first HTTP endpoint for the `apiservice` service. The value of the environment variable is the URL of the service endpoint. A named endpoint might be expressed as follows: +The preceding environment variable expresses the HTTP endpoint for the `apiservice` service. The value of the environment variable is the URL of the service endpoint. A named endpoint might be expressed as follows: ```Environment -services__apiservice__myendpoint__0 +APISERVICE_MYENDPOINT ``` In the preceding example, the `apiservice` service has a named endpoint called `myendpoint`. The value of the environment variable is the URL of the service endpoint. diff --git a/docs/fundamentals/orchestrate-resources.md b/docs/fundamentals/orchestrate-resources.md index 4c50f3a659..b5cbc72767 100644 --- a/docs/fundamentals/orchestrate-resources.md +++ b/docs/fundamentals/orchestrate-resources.md @@ -285,7 +285,7 @@ var frontend = builder.AddProject("frontend") .WithReference(api); ``` -This configuration injects an environment variable like `services__api__https__0=https://api.example.com/` into the frontend project, enabling service discovery through the standard .NET service discovery mechanisms. +This configuration injects an environment variable like `API_HTTPS=https://api.example.com/` into the frontend project, enabling service discovery through the standard .NET service discovery mechanisms. ### External service lifecycle diff --git a/docs/get-started/build-aspire-apps-with-nodejs.md b/docs/get-started/build-aspire-apps-with-nodejs.md index 2aaa6da893..cd56687a88 100644 --- a/docs/get-started/build-aspire-apps-with-nodejs.md +++ b/docs/get-started/build-aspire-apps-with-nodejs.md @@ -147,7 +147,7 @@ There are several key modifications from the original Angular template. The firs :::code language="javascript" source="~/aspire-samples/samples/AspireWithJavaScript/AspireJavaScript.Angular/proxy.conf.js"::: -The Aspire AppHost sets the `services__weatherapi__http__0` environment variable, which is used to resolve the "weatherapi" service endpoint. The preceding configuration proxies HTTP requests that start with `/api` to the target URL specified in the environment variable. +The Aspire AppHost sets the `WEATHERAPI_HTTPS` and `WEATHERAPI_HTTP` environment variables, which are used to resolve the "weatherapi" service endpoints. The preceding configuration proxies HTTP requests that start with `/api` to the target URL specified in the environment variable. Then include the proxy file to in the _angular.json_ file. Update the `serve` target to include the `proxyConfig` option, referencing to the created _proxy.conf.js_ file. @@ -217,7 +217,7 @@ As the `TheWelcome` integration is `mounted`, it calls the `/api/weatherforecast :::code language="typescript" source="~/aspire-samples/samples/AspireWithJavaScript/AspireJavaScript.Vue/vite.config.ts"::: -Additionally, the Vite config specifies the `server.proxy` property to forward requests to the "weatherapi" service. This is achieved by using the `services__weatherapi__http__0` environment variable, which is set by the Aspire AppHost. +Additionally, the Vite config specifies the `server.proxy` property to forward requests to the "weatherapi" service. This is achieved by using the `WEATHERAPI_HTTPS` and `WEATHERAPI_HTTP` environment variables, which are set by the Aspire AppHost. The final update from the template is made to the _TheWelcome.vue_ file. This file calls the `/api/WeatherForecast` endpoint to retrieve the weather forecast data, and displays the data in a table. It includes [CSS, HTML, and TypeScript updates](https://github.com/dotnet/aspire-samples/blob/ef6868b0999c6eea3d42a10f2b20433c5ea93720/samples/AspireWithJavaScript/AspireJavaScript.Vue/src/components/TheWelcome.vue). diff --git a/docs/testing/snippets/testing/mstest/AspireApp.Tests/EnvVarTests.cs b/docs/testing/snippets/testing/mstest/AspireApp.Tests/EnvVarTests.cs index d0bfbfd2dd..6b969f3ae7 100644 --- a/docs/testing/snippets/testing/mstest/AspireApp.Tests/EnvVarTests.cs +++ b/docs/testing/snippets/testing/mstest/AspireApp.Tests/EnvVarTests.cs @@ -21,7 +21,7 @@ public async Task WebResourceEnvVarsResolveToApiService() // Assert CollectionAssert.Contains(envVars, new KeyValuePair( - key: "services__apiservice__https__0", + key: "APISERVICE_HTTPS", value: "{apiservice.bindings.https.url}")); } } diff --git a/docs/testing/snippets/testing/nunit/AspireApp.Tests/EnvVarTests.cs b/docs/testing/snippets/testing/nunit/AspireApp.Tests/EnvVarTests.cs index e93ee69c51..9aef6e94a4 100644 --- a/docs/testing/snippets/testing/nunit/AspireApp.Tests/EnvVarTests.cs +++ b/docs/testing/snippets/testing/nunit/AspireApp.Tests/EnvVarTests.cs @@ -20,7 +20,7 @@ public async Task WebResourceEnvVarsResolveToApiService() // Assert Assert.That(envVars, Does.Contain( new KeyValuePair( - key: "services__apiservice__https__0", + key: "APISERVICE_HTTPS", value: "{apiservice.bindings.https.url}"))); } } diff --git a/docs/testing/snippets/testing/xunit/AspireApp.Tests/EnvVarTests.cs b/docs/testing/snippets/testing/xunit/AspireApp.Tests/EnvVarTests.cs index 434a1beb87..febd8169bb 100644 --- a/docs/testing/snippets/testing/xunit/AspireApp.Tests/EnvVarTests.cs +++ b/docs/testing/snippets/testing/xunit/AspireApp.Tests/EnvVarTests.cs @@ -22,7 +22,7 @@ public async Task WebResourceEnvVarsResolveToApiService() { var (key, value) = kvp; - return key is "services__apiservice__https__0" + return key is "APISERVICE_HTTPS" && value is "{apiservice.bindings.https.url}"; }); }