Make OTLP and resource service config optional in app host - #16046
Conversation
Make it so that aspire can use dynamic ports for `ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL`, `ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL` and other urls that previously had to be specifeid in `launchsettings.json` if they're missing. This does a number of things such as: - Make it easier to use a dashboard within tests - you can now enable the dashboad simply by setting `DistributedApplicationBuilderOptions.DisableDashboard = false` - A single file app host should now be possible, without needing to specify `aspire.config.json` or `apphost.run.json`
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16046Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16046" |
There was a problem hiding this comment.
Pull request overview
Updates Aspire dashboard/resource-service configuration to treat several URL settings as optional, enabling dynamic port allocation (reducing the need for launchSettings.json-pinned URLs) and making it easier to enable the dashboard in tests and single-file app host scenarios.
Changes:
- Relaxes transport/dashboard option validation so missing/blank URLs can succeed and be dynamically allocated.
- Auto-configures dashboard frontend + OTLP endpoints when configuration is missing/blank.
- Updates/extends tests and removes pinned dashboard/resource-service URL env vars from many playground launch profiles/config files.
Reviewed changes
Copilot reviewed 73 out of 77 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Hosting.Tests/Dashboard/TransportOptionsValidatorTests.cs | Updates expectations so missing/blank URLs validate successfully. |
| tests/Aspire.Hosting.Tests/Dashboard/DashboardResourceTests.cs | Adds coverage for dynamic OTLP + frontend endpoint auto-configuration. |
| tests/Aspire.Hosting.Tests/Dashboard/DashboardOptionsTests.cs | Adds coverage for blank OTLP endpoint normalization to null. |
| src/Aspire.Hosting/Dashboard/TransportOptionsValidator.cs | Makes app/OTLP/resource-service URL settings optional (only validate when present). |
| src/Aspire.Hosting/Dashboard/DashboardServiceHost.cs | Chooses default scheme for dynamic resource service hosting based on AllowUnsecuredTransport. |
| src/Aspire.Hosting/Dashboard/DashboardOptions.cs | Normalizes blank OTLP endpoint URLs to null; removes dashboard option validation. |
| src/Aspire.Hosting/Dashboard/DashboardEventHandlers.cs | Adds dynamic dashboard frontend endpoint when ASPNETCORE_URLS missing; always adds OTLP endpoint annotations. |
| playground/yarp/Yarp.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/withdockerfile/WithDockerfile.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/webpubsub/WebPubSub.AppHost/Properties/launchSettings.json | Removes pinned dashboard OTLP env var; updates applicationUrl host. |
| playground/waitfor/WaitForSandbox.DbSetup/Properties/launchSettings.json | JSON formatting fix (closing brace). |
| playground/waitfor/WaitForSandbox.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/TypeScriptApps/RpsArena/aspire.config.json | Removes pinned dashboard/resource-service endpoint env vars from profile. |
| playground/TypeScriptApps/RpsArena/apphost.run.json | Removes pinned dashboard/resource-service endpoint env vars; JSON formatting fix. |
| playground/TypeScriptApps/AzureFunctionsSample/AppHost/apphost.run.json | Removes pinned dashboard/resource-service endpoint env vars; JSON formatting fix. |
| playground/TypeScriptAppHost/apphost.run.json | Removes pinned dashboard/resource-service endpoint env vars. |
| playground/TestShop/TestShop.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/Stress/Stress.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/SqlServerScript/AppHost1/Properties/launchSettings.json | Removes pinned dashboard OTLP env var. |
| playground/SqlServerEndToEnd/SqlServerEndToEnd.DbSetup/Properties/launchSettings.json | JSON formatting fix (closing brace). |
| playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host; JSON formatting fix. |
| playground/signalr/SignalR.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/seq/Seq.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/Redis/Redis.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/Qdrant/Qdrant.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/PythonAppHost/apphost.run.json | Removes pinned dashboard/resource-service endpoint env vars (keeps MCP endpoint). |
| playground/python/Python.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/publishers/Publishers.DbSetup/Properties/launchSettings.json | JSON formatting fix (closing brace). |
| playground/publishers/Publishers.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/ProxylessEndToEnd/ProxylessEndToEnd.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/ProjectResourceExtensions/ProjectResourceExtensions.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/PostgresEndToEnd/PostgresEndToEnd.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/pipelines/Pipelines.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/ParameterEndToEnd/ParameterEndToEnd.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/orleans/Orleans.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/OracleEndToEnd/OracleEndToEnd.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/OpenAIEndToEnd/OpenAIEndToEnd.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/nats/Nats.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/mysql/MySqlDb.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/mongo/Mongo.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/milvus/MilvusPlayground.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/keycloak/Keycloak.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/kafka/KafkaBasic.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/JavaAppHost/aspire.config.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/HealthChecks/HealthChecksSandbox.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/GitHubModelsEndToEnd/GitHubModelsEndToEnd.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/FoundryEndToEnd/FoundryEndToEnd.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/FoundryAgentBasic/FoundryAgentBasic.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/FileBasedApps/apphost.settings.json | Adds Dashboard config section (DetailedErrors). |
| playground/FileBasedApps/apphost.run.json.old | Removes pinned dashboard/resource-service endpoint env vars. |
| playground/ExternalServices/ExternalServices.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/DotnetTool/DotnetTool.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/DevTunnels/DevTunnels.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/deployers/Deployers.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/DatabaseMigration/DatabaseMigration.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/CustomResources/CustomResources.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/CosmosEndToEnd/CosmosEndToEnd.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/cdk/CdkSample.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/BrowserTelemetry/BrowserTelemetry.AppHost/Properties/launchSettings.json | Removes pinned OTLP/resource-service endpoint env vars; updates applicationUrl host. |
| playground/bicep/BicepSample.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/AzureVirtualNetworkEndToEnd/AzureVirtualNetworkEndToEnd.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/AzureStorageEndToEnd/AzureStorageEndToEnd.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/AzureServiceBus/ServiceBus.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/AzureSearchEndToEnd/AzureSearch.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/AzureOpenAIEndToEnd/AzureOpenAIEndToEnd.WebStory/Properties/launchSettings.json | JSON formatting fix (closing brace). |
| playground/AzureOpenAIEndToEnd/AzureOpenAIEndToEnd.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/AzureKusto/AzureKusto.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/AzureFunctionsWithDts/AzureFunctionsWithDts.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/AzureFunctionsEndToEnd/AzureFunctionsEndToEnd.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/AzureDataLakeEndToEnd/AzureDataLakeEndToEnd.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/AzureContainerApps/AzureContainerApps.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/AzureAppService/AzureAppService.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/AzureAppConfiguration/AzureAppConfiguration.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/AspireWithNode/AspireWithNode.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/AspireWithMaui/AspireWithMaui.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/AspireWithJavaScript/AspireJavaScript.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
| playground/AspireEventHub/EventHubs.AppHost/Properties/launchSettings.json | Removes pinned dashboard/resource-service endpoint env vars; updates applicationUrl host. |
…ICE_ENDPOINT_URL` from default templates
|
Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
|
David Fowler (davidfowl)
left a comment
There was a problem hiding this comment.
When OTLP endpoint URLs are not specified (null/blank), CreateDashboardOtlpEndpointAnnotation always creates endpoints with "https" scheme, even when ASPIRE_ALLOW_UNSECURED_TRANSPORT=true.
The frontend dashboard endpoint correctly respects allowUnsecureTransport to choose http vs https (line ~422-424), but the OTLP endpoints dont — CreateDashboardOtlpEndpointAnnotation hardcodes "https" when endpointUrl is null (line ~642).
This means when users set ASPIRE_ALLOW_UNSECURED_TRANSPORT=true and dont specify OTLP URLs, the dashboard will try to bind OTLP endpoints using HTTPS, which will fail without dev certificates — defeating the purpose of the flag.
Suggested fix: Pass allowUnsecuredTransport to CreateDashboardOtlpEndpointAnnotation and use it for the default scheme:
uriScheme: allowUnsecuredTransport ? "http" : "https"Also missing a test case combining allowUnsecuredTransport=true with blank OTLP URLs to verify they use HTTP.
|
Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
|
James Newton-King (JamesNK)
left a comment
There was a problem hiding this comment.
1 issue found: a bug where CORS configuration for the OTLP HTTP endpoint is silently skipped when using dynamic ports (the new default).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Pushed What changed:
Validation: dotnet test --project tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj --no-launch-profile -- --filter-class "*.DashboardResourceTests" --filter-class "*.DashboardEventHandlersTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"Result: 51 passed, 0 failed. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Pushed follow-up The endpoint creation behavior was already aligned: dynamic OTLP/HTTP is added only when neither OTLP endpoint is configured, while explicit gRPC-only or HTTP-only configuration remains unchanged. The follow-up tightens startup summary logging so explicit OTLP URLs keep using the configured values, and allocated endpoint URLs are only resolved for dynamic defaults. Added a regression test for that explicit-config case. Validation now covers 52 dashboard tests, all passing: dotnet test --project tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj --no-launch-profile -- --filter-class "*.DashboardResourceTests" --filter-class "*.DashboardEventHandlersTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true" |
|
Alex Crome (@afscrome) I pushed some changes to your branch based on the linked pr - I accidentally duplicated some of the work done here. |
|
Ran PR dogfood testing for the current head Result: passed for the dynamic dashboard endpoint scenario. What was tested:
Note: the first attempt from a long macOS temp path hit the known Unix domain socket path-length limit. Retried from |
I reverted this because it's different from the frontend URL behavior. It prefers the dynamic URL when printing a value to the user. And I don't understand what scenario this is fixing. If it needs to be this way then it can change back in another commit or PR. |
Refactor DashboardEventHandlers to compute an EndpointGenerationContext during dashboard URL parsing. When OTLP endpoints are dynamically generated (no explicit URL configured), they now inherit the TargetHost from the dashboard URL with a matching scheme, falling back to localhost. Add test verifying OTLP endpoint TargetHost inheritance from dashboard URLs.
|
Ok, I figured out the problem the change was to solve. No target host was set on the generated URLs so they were localhost instead of a localhost.dev host name. Fixed by passing the target host to the generated OLTP endpoints. |
…ertions OTLP endpoints always use HTTPS and only inherit the dashboard's localhost TLD host when the dashboard scheme matches the endpoint context scheme. Add expectedOtlpHost parameter to correctly assert per test case.
|
Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
|
Extract a shared helper method that logs scheme, host, and port (or <random>) when dashboard endpoints are added. Reuse it for both frontend and OTLP endpoint configuration paths.
Co-authored-by: James Newton-King <james@newtonking.com>
69c48db
into
microsoft:main


Description
Make it so that aspire can use dynamic ports for
ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL,ASPIRE_RESOURCE_SERVICE_ENDPOINT_URLand other urls that previously had to be specifeid inlaunchsettings.jsonif they're missing.This does a number of things such as:
Make it easier to use a dashboard within tests - you can now enable the dashboad simply by setting
DistributedApplicationBuilderOptions.DisableDashboard = false, and not needing to set a bunch of magic env vars. (Which then get ignored anyway due to Port randomisation for testing)A single file app host should now be possible, without needing to specify
aspire.config.jsonorapphost.run.json. (Not quite possible yet due to Dashboard doesn't load ifASPNETCORE_ENVIRONMENTis notDevelopment#16069)Helps towards #15999 and #13746
Checklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue: