0% found this document useful (0 votes)
64 views57 pages

Dotnetconf2024-Simplify The Development of Distributed Applications With .NET Aspire

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views57 pages

Dotnetconf2024-Simplify The Development of Distributed Applications With .NET Aspire

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 57

Simplify the development of distributed

applications with .NET Aspire


Thang Chung
November 23, 2024
Thang Chung
Technical Manager at NashTech VN
Microsoft Azure MVP

Creator of Vietnam Microservices Group on Facebook (>20k members):


https://www.facebook.com/groups/645391349250568
Experience: >18 years in software consult, design, development, and deployment
software for outsourcing, product, and startup companies.
Expertise in cloud computing, cloud-native platform, serverless, and
WebAssembly/WASI.
Blog: https://dev.to/thangchung
GitHub: https://github.com/thangchung
LinkedIn: https://www.linkedin.com/in/thangchungatwork
X (former Twitter): @thangchung
Agenda

01 02 03
.NET Aspire What’s new in .NET Intelligent Apps
Aspire 9? with .NET Aspire
01
.NET Aspire
Every App Needs

Observability Resiliency Scalability Manageability


.NET gives you a lot in the box

Observability Resiliency Scalability Manageability

New Polly based AOT Certificate auto-rotation


Built in metrics with dimensions
resiliency packages (increased density) support in Kestrel

DI integration for metrics SignalR Stateful Reconnect Performance

Better Logging support


Chiseled Ubuntu
(faster, can object serialization)

Enrichment

Redaction

Testing fakes for Logging & Metrics


It’s Still Not Easy

Complex Getting Started Choices Paved Path


A cloud ready stack for building observable,
production ready, distributed applications

Smart Defaults Developer Dashboard

Orchestration Service Discovery

Integrations Deployment
A cloud ready stack for building observable,
production ready, distributed applications

Smart Defaults Developer Dashboard

Orchestration Service Discovery

Integrations Deployment
.NET Aspire Service Defaults

Observability Resiliency Health Checks


DEMO

.NET Aspire - Smart Defaults

Clone: https://github.com/thangchung/practical-dotnet-aspire
A cloud ready stack for building observable,
production ready, distributed applications

Smart Defaults Developer Dashboard

Orchestration Service Discovery

Integrations Deployment
.NET Aspire

Developer Dashboard

Structured Logs

Metrics

Distributed Traces

Dependencies
Integrating the Developer Dashboard

Standalone .NET Aspire App Host

docker run --rm -it `


-p 18888:18888 `
-p docker
4317:18889 -d `
run --rm -it -p 18888:18888 -p 4317:18889 -d --name aspire-dashboard
mcr.microsoft.com/dotnet/aspire-dashboard:8.0.0
--name aspire-dashboard `
mcr.microsoft.com/dotnet/aspire-dashboard:8.0.0
A cloud ready stack for building observable,
production ready, distributed applications

Smart Defaults Developer Dashboard

Orchestration Service Discovery

Integrations Deployment
Orchestration Before
.NET Aspire

Orchestration

var builder = DistributedApplication.CreateBuilder(args);

builder.AddProject<Projects.ApiService>("apiservice");

builder.AddProject<Projects.Web>("webfrontend");

builder.Build().Run();
After with .NET Aspire
DEMO

.NET Aspire - Orchestration

Clone: https://github.com/thangchung/practical-dotnet-aspire
A cloud ready stack for building observable,
production ready, distributed applications

Smart Defaults Developer Dashboard

Orchestration Service Discovery

Integrations Deployment
Service Discovery Before

{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ProductEndpoint": "http://localhost:5228",
"ProductEndpointHttps": "https://localhost:7130"
}

builder.Services.AddHttpClient<ProductService>(c =>
{
var url = builder.Configuration["ProductEndpoint"] ?? throw new
InvalidOperationException("ProductEndpoint is not set");

c.BaseAddress = new(url);
});
Service Discovery
var builder = DistributedApplication.CreateBuilder(args);

var apiService = builder.AddProject<Projects.ApiService>("apiservice");

builder.AddProject<Projects.Web>("webfrontend")
.WithReference(apiService);

builder.Build().Run();

builder.Services.AddHttpClient<WeatherApiClient>(client =>
{
client.BaseAddress = new("https+http://apiservice");
});
There are still connection strings
DEMO

.NET Aspire - Service Discovery

Clone: https://github.com/thangchung/practical-dotnet-aspire
A cloud ready stack for building observable,
production ready, distributed applications

Smart Defaults Developer Dashboard

Orchestration Service Discovery

Integrations Deployment
.NET Aspire

Integrations Nuget Gallery | Home

https://www.nuget.org
.NET Aspire Automatically will pull
down container
image and start it in
Docker or Podman!
Hosting Integration
var builder = DistributedApplication.CreateBuilder(args);

var postgres = builder.AddPostgres("postgres").WithPgAdmin();


var db = postgres.AddDatabase("db");

var cache = builder.AddRedis("cache");

var apiService = builder.AddProject<Projects.ApiService>("apiservice")


.WithReference(db);

builder.AddProject<Projects.Web>("webfrontend")
.WithReference(apiService)
.WithReference(cache);

builder.Build().Run();
.NET Aspire

Client Integration
var builder = WebApplication.CreateBuilder(args);

builder.AddServiceDefaults(); Configures service


builder.AddRedisOutputCache("cache"); with retries,
corresponding health
builder.Services.AddRazorComponents() checks, logging, and
.AddInteractiveServerComponents(); telemetry!!!!
var app = builder.Build();

app.UseOutputCache();

app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();

app.MapDefaultEndpoints();

app.Run();
DEMO

.NET Aspire - Integrations

Clone: https://github.com/thangchung/practical-dotnet-aspire
A cloud ready stack for building observable,
production ready, distributed applications

Smart Defaults Developer Dashboard

Orchestration Service Discovery

Integrations Deployment
Flexible Integrations & Deployment

How You Do AWS CDK Azure Dev CLI Visual Studio


It Today!
02
.NET Aspire – What’s new in .NET Aspire 9?
Some important features I applied for
practical-dotnet-aspire
Check it out…
No longer need a .NET workload
Waiting for dependencies
Resource health checks
Persistent containers
Manage resource lifecycle
Browser telemetry support
The dashboard supports OpenTelemetry Protocol (OTLP) over HTTP and cross-origin resource sharing (CORS).
These features unlock the ability to send OpenTelemetry from browser apps to the .NET Aspire dashboard.
OpenAI (Preview)
03
.NET Aspire – Intelligent Apps with .NET Aspire
Sample: eShopSupport
https://github.com/dotnet/eShopSupport
Public site

Outdoor Activities eCommerce Site Customer

My support enquiries

ID Date Type Product

23433 Today Returns Bäevolk 4-person tent View >

23419 Fri 5 May Question TCX Kayak 2000 View >

+ Create new enquiry


Staff web UI Semantic search
Summarization

Tickets Staff

272 open 15923 closed Search…

# Date Type Title Satisfaction


23433 Today Returns Return of Bäevolk 4-person tent OK
23419 Today Question Asks how to update kayak firmware Great
23414 Yesterday Question Asks what other colors are available OK
23413 Yesterday Complaint T-Shirt printing inadequate quality Bad
23407 Yesterday Returns Delivery late; return initiated OK
23399 … … … OK
23287 … … … Bad

Classification
23244 … … … OK

23243 … … …
Sentiment score
23190 … … … …
Staff web UI

Q&A
Classification Semantic search (RAG)
Ticket 23419 Staff

Case type: Question Status: Open


Assistant
Summarization Customer: Customer McCustomer Product: TCX Kayak 2000
What does the manual say
My question my question about this?
Summary: Customer wishes answer
to perform backflips and asks how to
my question blah blah
update kayak firmware.
Support agent Page 44 of the manual states
that backflips are supported
Thanks for your enquiry! The TCX as of firmware version 3.17.
kayak supports blah blah blah.
Link: Manual.pdf page 44
Customer
OK yeah but what about blah blah blah
because my nan says blah blah and my
friend Dave says you can but blah blah
Typeahead Citation
(content generation)
We have looked into this, and found that the TCX Kayak model 2000 Ask the AI assistant…
does support backflips as of v3.17. To upgrade, please see http://...
DEMO

.NET Aspire – Microsoft.Extensions.AI (Seed data and Sematic Search)

Clone: https://github.com/thangchung/practical-dotnet-aspire
That’s enough for today…
Get .NET 9
Download .NET 9
aka.ms/get-dotnet-9
More on
https://learn.microsoft.com/en-
us/dotnet/aspire/whats-new/dotnet-aspire-
9
.NET Aspire

Learning Resources .NET Aspire Videos

aka.ms/letslearn/dotnet/aspire aka.ms/aspire/videos

Documentation Engage with team on GitHub

aka.ms/dotnet-aspire github.com/dotnet/aspire

Thang Chung @thangchung


NashTech https://www.linkedin.com/in/thangchungatwork
Thank you

You might also like