.NET Aspire sample with Dapr

Read the associated blog post: .NET Aspire is the best way to experiment with Dapr during local development.

This is a sample .NET Aspire app host that orchestrates three services:

  1. An ASP.NET Core minimal API named "alice" that uses Dapr service invocation to call the "bob" service in order to retrieve the weather forecast. The results are then cached in a Dapr state store.
  2. An ASP.NET Core minimal API named "bob" that returns weather forecast data, but the endpoint is voluntarily flaky and can return errors. When a weather forecast is successfully returned to a client, the "bob" service will publish an event using Dapr pub/sub.
  3. A Node.js express app named "carol" that listens to the "bob" service events of weather forecasts being published and logs them to the console.
flowchart TD
    A[Alice]
    B[Bob]
    C[Carol]
    SS[State store]

    A --> |Get weather forecast| B
    A --> |Read/write cached weather data| SS
    B -.-> |Notify weather data requested| C
Loading

All the services are instrumented using OpenTelemetry to collect traces, logs, and metrics.

Because the "bob" service is flaky, a Dapr resiliency policy is configured to retry the service invocation. The corresponding Dapr resource is loaded by the "alice" service Dapr sidecar.

Requirements

Running the apps

  • Clone this repository.
  • Execute dotnet run inside the AspireDaprDemo.AppHost/ directory.
  • Browse to https://localhost:17262 to open the .NET Aspire dashboard.
  • Click on the first endpoint of the "alice" service to retrieve the weather forecast from "bob" and let "carol" log the event.
  • Use the "Traces" view to monitor the operation.

dashboard_resources

distributed_trace