Skip to content

Update samples for Aspire 13.3 APIs#1668

Open
IEvangelist wants to merge 1 commit into
mainfrom
ievangelist/dapine-aspire-api-updates
Open

Update samples for Aspire 13.3 APIs#1668
IEvangelist wants to merge 1 commit into
mainfrom
ievangelist/dapine-aspire-api-updates

Conversation

@IEvangelist
Copy link
Copy Markdown
Member

@IEvangelist IEvangelist commented Jun 2, 2026

Summary

  • Add Aspire.Hosting.Browsers/browser-log instrumentation to existing frontend samples.
  • Refresh selected JavaScript publishing patterns to use PublishAsStaticWebsite where it preserves sample intent.
  • Bind deployable resources to declared compute environments in deployment-focused samples.
  • Update the Azure Functions sample to use the non-generic AddAzureFunctionsProject(name, projectPath) overload.
  • Refresh the custom resources sample with lifecycle event handling and structured command output.
  • Remove redundant Aspire.Hosting.AppHost references from AppHost SDK projects.

Closes #1626

Validation

  • aspire restore --non-interactive for updated TypeScript AppHost samples
  • npm exec --yes tsc -- --noEmit -p tsconfig.apphost.json for updated TypeScript AppHost samples
  • Targeted dotnet build for changed sample solutions/AppHosts
  • dotnet build .\tests\SamplesIntegrationTests\SamplesIntegrationTests.csproj --no-restore --nologo --verbosity minimal --tl:off /m:1

Note: dotnet test .\tests\SamplesTests.slnx --no-build --nologo --verbosity minimal --tl:off /m:1 was attempted, but stopped after 10 minutes without progress output.

Add browser-log instrumentation to frontend samples, refresh selected JavaScript publishing patterns, bind deployable resources to compute environments, update the Azure Functions sample overload, refresh custom resource APIs, and remove redundant AppHost package references.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@IEvangelist IEvangelist force-pushed the ievangelist/dapine-aspire-api-updates branch from f119dfc to 14583a3 Compare June 2, 2026 18:16
@IEvangelist IEvangelist marked this pull request as ready for review June 2, 2026 18:27
Copilot AI review requested due to automatic review settings June 2, 2026 18:27
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

Updates multiple Aspire samples to align with newer (13.1–13.3+) hosting APIs and recommended patterns, including browser telemetry instrumentation, updated JavaScript publishing approaches, and explicit compute-environment binding for deployable resources.

Changes:

  • Add Aspire.Hosting.Browsers / WithBrowserLogs() across frontend-oriented samples and adjust test infrastructure to ignore browser-log command resources during startup waits.
  • Refresh JavaScript/Vite publishing patterns in select samples (e.g., PublishAsStaticWebsite, static-file publishing via YARP) and update documentation accordingly.
  • Bind deployable resources to declared compute environments (WithComputeEnvironment(...)) and remove redundant explicit Aspire.Hosting.AppHost references where Aspire.AppHost.Sdk already supplies it.

Reviewed changes

Copilot reviewed 35 out of 35 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/SamplesIntegrationTests/Infrastructure/DistributedApplicationExtensions.cs Skip BrowserLogs command resources during startup wait logic to prevent hangs.
samples/volume-mount/VolumeMount.AppHost/VolumeMount.AppHost.csproj Remove redundant Aspire.Hosting.AppHost package reference.
samples/vite-yarp-static/aspire.config.json Add Aspire.Hosting.Browsers package for browser telemetry.
samples/vite-yarp-static/apphost.mts Enable browser logs and bind YARP to Docker Compose compute environment.
samples/vite-react-fastapi/aspire.config.json Add Aspire.Hosting.Browsers package for browser telemetry.
samples/vite-react-fastapi/apphost.mts Bind API/YARP to compute environment and enable browser logs on YARP.
samples/vite-csharp-postgres/aspire.config.json Add Aspire.Hosting.Browsers package for browser telemetry.
samples/vite-csharp-postgres/apphost.mts Bind Postgres/API to compute environment; enable browser logs on frontend resource.
samples/rag-document-qa-svelte/aspire.config.json Add Aspire.Hosting.Browsers package for browser telemetry.
samples/rag-document-qa-svelte/apphost.mts Enable browser logs on Vite frontend resource.
samples/polyglot-task-queue/aspire.config.json Add Aspire.Hosting.Browsers package for browser telemetry.
samples/polyglot-task-queue/apphost.mts Bind deployables to Docker Compose compute environment; enable browser logs on frontend.
samples/orleans-voting/OrleansVoting.AppHost/OrleansVoting.AppHost.csproj Remove redundant Aspire.Hosting.AppHost package reference.
samples/node-express-redis/aspire.config.json Add Aspire.Hosting.Browsers package for browser telemetry.
samples/node-express-redis/apphost.mts Bind Redis/API/YARP to compute environment and enable browser logs on YARP.
samples/Metrics/MetricsApp.AppHost/MetricsApp.AppHost.csproj Remove redundant Aspire.Hosting.AppHost package reference.
samples/image-gallery/README.md Update documentation/diagram to reflect static-website publishing model.
samples/image-gallery/apphost.cs Add browser logs, bind compute environment, and switch frontend publishing to PublishAsStaticWebsite.
samples/health-checks-ui/HealthChecksUI.AppHost/HealthChecksUI.AppHost.csproj Remove redundant Aspire.Hosting.AppHost package reference.
samples/health-checks-ui/HealthChecksUI.AppHost/AppHost.cs Bind resources to Docker Compose compute environment.
samples/database-migrations/DatabaseMigrations.AppHost/DatabaseMigrations.AppHost.csproj Remove redundant Aspire.Hosting.AppHost package reference.
samples/database-containers/DatabaseContainers.AppHost/DatabaseContainers.AppHost.csproj Remove redundant Aspire.Hosting.AppHost package reference.
samples/custom-resources/CustomResources.AppHost/TestResource.cs Add an “inspect” command returning structured output from a custom resource.
samples/custom-resources/CustomResources.AppHost/CustomResources.AppHost.csproj Remove redundant Aspire.Hosting.AppHost package reference.
samples/custom-resources/CustomResources.AppHost/AppHost.cs Add lifecycle event handling with structured logging.
samples/client-apps-integration/ClientAppsIntegration.AppHost/ClientAppsIntegration.AppHost.csproj Remove redundant Aspire.Hosting.AppHost package reference.
samples/aspire-with-python/apphost.cs Enable browser logs and update frontend publishing to PublishAsStaticWebsite.
samples/aspire-with-node/AspireWithNode.AppHost/AspireWithNode.AppHost.csproj Add Aspire.Hosting.Browsers and remove redundant Aspire.Hosting.AppHost reference.
samples/aspire-with-node/AspireWithNode.AppHost/AppHost.cs Enable browser logs for the Node frontend.
samples/aspire-with-javascript/AspireJavaScript.AppHost/AspireJavaScript.AppHost.csproj Add Aspire.Hosting.Browsers and remove redundant Aspire.Hosting.AppHost reference.
samples/aspire-with-javascript/AspireJavaScript.AppHost/AppHost.cs Enable browser logs and update JavaScript publishing to PublishAsStaticWebsite.
samples/aspire-with-azure-functions/ImageGallery.AppHost/ImageGallery.AppHost.csproj Remove redundant Aspire.Hosting.AppHost package reference.
samples/aspire-with-azure-functions/ImageGallery.AppHost/AppHost.cs Use non-generic AddAzureFunctionsProject(name, projectPath) and bind deployables to compute environment.
samples/aspire-with-azure-functions/Directory.Packages.props Remove central Aspire.Hosting.AppHost package version as redundant.
samples/aspire-shop/AspireShop.AppHost/AspireShop.AppHost.csproj Remove redundant Aspire.Hosting.AppHost package reference.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@adamint
Copy link
Copy Markdown
Member

adamint commented Jun 2, 2026

nit: title says 13.3 APIs, but the changed packages are 13.4.0 (plus the browser logs preview). Could you update the title/body to 13.4 so reviewers do not chase the wrong release?

**Static Website Publishing** - Publish the Vite app as a static website with API proxying:
```csharp
api.PublishWithContainerFiles(frontend, "wwwroot");
frontend.PublishAsStaticWebsite("/api", api);
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.

could we make this snippet copy/paste accurate? frontend is not declared in the AppHost anymore after this change, so I think either the snippet should show the chained call or capture var frontend = builder.AddViteApp(...) first.


// BrowserLogs resources are dashboard command resources; they do not have a
// service lifecycle to wait for during AppHost startup tests.
if (resource.GetType().FullName?.Contains("BrowserLogs", StringComparison.Ordinal) == true)
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.

nit: maybe leave a TODO here to switch this to a typed check once BrowserLogs is GA? matching on FullName.Contains("BrowserLogs") is fine as a bridge, but it feels a little fragile long-term.

IEvangelist added a commit to microsoft/aspire.dev that referenced this pull request Jun 5, 2026
Regenerates `src/frontend/src/data/samples.json` from microsoft/aspire-samples#1668 (`Update samples for Aspire 13.3 APIs`) so the sample detail pages on aspire.dev pick up the new APIs that PR exercises.

Notable AppHost-code changes mirrored into the data file:

- `aspire-with-azure-functions`: uses `WithComputeEnvironment(env)` and switches `AddAzureFunctionsProject` to the typed-name overload.

- `aspire-with-javascript`: adds `WithBrowserLogs()` for Angular/React/Vue/Vite, swaps `PublishAsDockerFile` for `PublishAsStaticWebsite`, and adds `WithNpm(installCommand: \"ci\")` for npm-ci installs.

- `aspire-with-node`: adds `WithBrowserLogs()` to the Node frontend.

- `aspire-with-python`: adds `Aspire.Hosting.Browsers` package reference and `WithBrowserLogs()` + `PublishAsStaticWebsite` on the Vite frontend.

- `image-gallery`: switches to `WithComputeEnvironment(env)` and the typed-name `AddAzureFunctionsProject` overload (plus README updates).

- `node-express-redis` / `polyglot-task-queue` / `rag-document-qa-svelte` / `vite-csharp-postgres` / `vite-react-fastapi` / `vite-yarp-static`: pick up TypeScript AppHost `apphost.mts` updates and `aspire.config.json` additions.

- `health-checks-ui` / `custom-resources`: pick up new `TestResource` plumbing and AppHost updates.

Also normalizes a handful of em-dash characters from `\\u2014` ASCII-escapes back to literal Unicode (artifact from an earlier intermediate edit by the typo-fix script in #1189); `update-samples.ts` natively writes literal Unicode, so this restores the file to the script's native output format. JSON parses identically either way.

Generated by temporarily pointing `update-samples.ts` at the PR's head branch (`ievangelist/dapine-aspire-api-updates`) via a `SAMPLES_BRANCH` env-var override, then reverting the script edit. `href` fields remain anchored to `tree/main` so links keep working after #1668 merges.

Verified: 62/62 `custom-components.vitest.test.ts` pass, `pnpm lint` clean, `samples.json` parses (26 samples).

Co-authored-by: David Pine <7679720+IEvangelist@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

var functions = builder.AddAzureFunctionsProject<Projects.ImageGallery_Functions>("functions")
var functions = builder.AddAzureFunctionsProject("functions", "../ImageGallery.Functions/ImageGallery.Functions.csproj")
.WithComputeEnvironment(env)
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.

Why?

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.

Update samples for Aspire 13.1-13.3 APIs

4 participants