.Net Aspire - A Brief Introduction

March 16, 2024

After recently seeing a demo of .Net Aspire, I’ve been playing around with some basics and, I have to say, I’m really impressed. I’m not sure I’d start moving deployments over to it just yet, but it definitely has other uses.

The compelling thing that I found in Aspire was this:

var builder = DistributedApplication.CreateBuilder(args);
var test = builder.AddMySql("test");
var db = test.AddDatabase("testdb");
builder.AddRedis("redis");
builder.AddProject<Projects.AspireApp1_Web>("webfrontend");
builder.Build().Run();

This is it’s own project, but in 6 lines of code, I have a Redis cache and a MySql database running locally. Behind the scenes this needs docker, but I didn’t need to write or maintain a docker script - I pressed F5 and this whole set-up appeared.

You can see what it’s created in the dashboard, too:

Dashboard

This gives logs, traces, and metrics for all resources, along with the console output.

This might not seem much at first glance, but if you want a SQL Sever DB, a Redis Cache, your web app and web service all running at the same time, this means you don’t need to fetch all those images, create a docker compose file, play about until it’s all working together - just type 6 or 7 lines of .Net code and press F5.

Not sure this makes sense as a release strategy (at least not yet), but for local development it’s really compelling!

References

.Net Aspire Fundamentals

.Net Aspire Getting Started



Profile picture

A blog about one man's journey through code… and some pictures of the Peak District
Twitter

© Paul Michaels 2024