First of all, I have a hobby project called WinampToSpotify which helps you transfer your local mp3 folder archieve to spotify as a playlist. I decided to add .Net Aspire to WinampToSpotifyWeb solution. First article will be about adding .Net Aspire to project and second article will be about sending custom metrics to Aspire Dashboard and Prometheus.
What is .Net Aspire?
Adding Service Defaults
- Right-click on the solution and select Add > New Project.
- Select the .NET Aspire Service Defaults project template.
- Name the project ServiceDefaults (any name would work if you’re feeling creative, but the instructions in this post assume you’re using ServiceDefaults).
- Click Next > Create.
Configure Service Defaults
Add a reference to the ServiceDefaults project in the WinampToSpotifyWeb project:
- Right-click on the Api project and select Add > Reference. Check the ServiceDefaults project and click OK.
- Right-click on the MyWeatherHub project and select Add > Reference.
- Check the ServiceDefaults project and click OK.
In WinampToSpotifyWeb project, update their Program.cs files,adding the following line immediately after their
var app = builder.Build();line:
app.MapDefaultEndpoints();In WinampToSpotifyWeb project, update their Program.cs files, adding the following line immediately after their
var builder = WebApplication.CreateBuilder(args);line:
builder.AddServiceDefaults();
Simplify launch and add a fancy dashboard with AppHost
Adding an AppHost project
This is the standard “add project” steps we ran through before with ServiceDefaults, but this time we’re going to pick “.NET Aspire App Host” as the project template. In Visual Studio 2022 or Visual Studio Code with the C# DevKit installed:
Right-click on the solution and select Add > New Project.
Select the .NET Aspire App Host project template.
Name the project AppHost (again, any name would work).
Click Next > Create.
Add project references
- Add a reference to the WinampToSpotifyWeb projects in the new AppHost project:
- Right-click on the AppHost project and select Add > Reference.
Check the WinampToSpotifyWeb project and click OK.
Orchestrate the Application
In the AppHost project, update the Program.cs file, adding the following line immediately after the var builder = DistributedApplication.CreateBuilder(args);
var app = builder.AddProject<WinampToSpotifyWeb>("winamptospotifyweb");
We got the dashboard.
We have Resources Tab,Console Tab for console logs, Structured Tab for structured logs, Traces tab for traces, Metrics tab for metrics.
You can see my code changes on my github repo commit code changes
I will continue article with sending custom metrics to Aspire Dashboard and Prometheus, Grafana.




Top comments (0)