Skip to content
Docs Try Aspire

Samples

Explore a curated collection of official Aspire sample projects. Each sample is a fully functional application you can clone and run to learn patterns for databases, messaging, cloud services, and more.

15 samples
Screenshot of the Aspire Shop sample

Aspire Shop

The app consists of four .NET services:

  • AspireShop.Frontend: This is an ASP.NET Core Blazor app that displays a paginated catlog of products and allows users to add products to a shopping cart.
  • AspireShop.CatalogService: This is an HTTP API that provides access to the catalog of products stored in a PostgreSQL database.
Blazor C# Databases gRPC PostgreSQL +1
Screenshot of the Image Gallery sample

Image Gallery

The app consists of two services:

  • ImageGallery.Frontend: This is a Blazor app that displays a for uploading of images, showing thumbnails of images in a grid.
  • ImageGallery.Functions: This is an Azure Function triggered by the arrival of a new blob using a Functions Blob Trigger.
Azure Azure Functions Blazor C#
Screenshot of the Integrating Angular, React, and Vue with Aspire sample

Integrating Angular, React, and Vue with Aspire

This sample demonstrates using the Aspire JavaScript hosting integration to configure and run client-side applications.

C# Dashboard JavaScript Node.js

Integrating a Node.js app within an Aspire application

This sample demonstrates integrating a Node.js app and an ASP.NET Core HTTP API using Aspire.

The sample consists of two apps:

  • NodeFrontend: This is a simple Express-based Node.js app that renders a table of weather forecasts retrieved from a backend API and utilizes a Redis cache.
  • AspireWithNode.AspNetCoreApi: This is an ASP.NET Core HTTP API that returns randomly generated weather forecast data.
C# JavaScript Node.js Redis

Integrating a FastAPI (Python) app within an Aspire application

This sample demonstrates integrating a FastAPI (Python) app and a JavaSript frontend using Aspire.

The sample consists of two apps:

  • app: This is a simple FastAPI-based Python app that returns randomly generated weather forecast data.
  • frontend: This is a Vite-based React app that renders the weather forecast data.
C# JavaScript Node.js Python
Screenshot of the Working with client apps in an Aspire application sample

Working with client apps in an Aspire application

This sample demonstrates working with client apps such as WinForms, WPF, etc., in an Aspire app, such that the client app is launched along with the AppHost project, can resolve services via service discovery, and logs, traces, and metrics are sent via OpenTelemetry to the dashboard.

C# Dashboard Metrics
Screenshot of the Working with container-built resources in a Aspire application sample

Working with container-built resources in a Aspire application

This sample demonstrates integrating applications into a Aspire app via Dockerfiles and container-based builds. This is especially helpful to integrate applications written in languages that Aspire does not have a native integration for, or to reduce the prerequisites required to run the application.

C# Dashboard Docker Metrics

Writing custom resources for Aspire hosting integrations

This sample demonstrates how to write custom resources for Aspire hosting integrations. This is useful when you want to integrate something into the Aspire development experience as a resource that isn't an executable or container. Custom resources can particpate in the Aspire development experience, including the dashboard, and can be used to integrate with other tools or services.

Custom resources are defined using C# and generally consist of a class that implements the IResource interface and some extension methods to enable adding them to an IDistributedApplicationBuilder. Custom resources can publish and respond to events to give them "life" and allow them to interact with the rest of the Aspire application.

In this sample, we define a TalkingClock custom resource that spawns child ClockHand resources that tick on and off every second. We also define a TestResource custom resource that simply cycles through a set of states.

Read more about the Aspire resource model here.

C# Dashboard
Screenshot of the Working with database containers in a Aspire application sample

Working with database containers in a Aspire application

This sample demonstrates working with database containers in a Aspire app, using the features of the underlying container image to modify the default database created during container startup. This is especially helpful when not using an ORM like Entity Framework Core that can run migrations on application startup (e.g., as in the Aspire Shop sample) and handle cases when the database configured in the AppHost is not yet created.

C# Dashboard Databases Docker EF Core +4

Database migrations with Entity Framework Core sample app

This sample demonstrates how to use Entity Framework Core's migrations feature with Aspire.

The sample has three important projects:

  • DatabaseMigrations.ApiService - A web app that uses the database.
  • DatabaseMigrations.MigrationService - A background worker app that applies migrations when it starts up.
  • DatabaseMigrations.ApiModel - The EF Core context and entity types. This project is used by both the API and migration service.

DatabaseMigrations.ApiService and DatabaseMigrations.MigrationService reference a SQL Server resource. During local development the SQL Server resource is launched in a container.

C# Databases EF Core Migrations PostgreSQL +1
Screenshot of the Aspire metrics sample app sample

Aspire metrics sample app

This is a simple .NET app that shows off collecting metrics with OpenTelemetry and exporting them to Prometheus and Grafana for reporting.

C# Dashboard Grafana Metrics Prometheus
Screenshot of the Standalone Aspire dashboard sample app sample

Standalone Aspire dashboard sample app

View telemetry from any app in the Aspire dashboard. The dashboard supports running standalone, and apps configured with an OpenTelemetry SDK can send it data.

C# Dashboard Docker gRPC Metrics
Screenshot of the Persistent Volume sample

Persistent Volume

This sample demonstrates how to configure a SQL Server container to use a persistent volume in Aspire, so that the data is persisted across app launches. This method can be used to persist data across instances of other container types configured in Aspire apps too, e.g. PostgreSQL, Redis, etc.

Azure Azure Storage Blazor C# Dashboard +8