NET Aspire - NET Conf IL 2024 - Tamir Dresher.pdf
- 3. Creating a local dev env for
Distributed Applications /
Microservices
is hard!
- 5. eShop as an example
• Running multiple
interconnected services
• Expressing the
system structure
• Configuring
service
discovery
• Multiple
instances
• Making it production
grade: reliability, health
checks, logging,
telemetry etc.
• Local experience for
observability and
debuggability
https://github.com/dotnet/eshop
- 6. .NET Aspire
Opinionated, cloud ready stack for building observable, production ready,
distributed applications. .NET
.NET Aspire
Composition & Orchestration Components Tools
• Modeling language for
defining the system resources
and their dependencies
• A runtime to for running and
connecting multi-project
applications and their
dependencies
• Dashboard
• Distributed App VS support
• Service Defaults
• Publishing utils
• Packages of commonly used
services, such as Redis or
Postgres, with standardized
interfaces and capabilities
- 7. .NET Aspire
Opinionated, cloud ready stack for building observable, production ready,
distributed applications. .NET
.NET Aspire
Composition & Orchestration Components Tools
• Modeling language for
defining the system resources
and their dependencies
• A runtime to for running and
connecting multi-project
applications and their
dependencies
• Dashboard
• Distributed App VS support
• Service Defaults
• Publishing utils
• Packages of commonly used
services, such as Redis or
Postgres, with standardized
interfaces and capabilities
Orchestration Components Tools
Behind the
scenes
- 13. Q: Where is the link between ‘webfrontend’ and ‘cache’?
A: Aspire set the env callback to set env-var with the url
Orchestration Components Tools
Behind the
scenes
- 15. A few interesting examples
Resource specific declarative
config
Multiple instances
External JS app
Orchestration Components Tools
Behind the
scenes
- 16. .NET Aspire
Opinionated, cloud ready stack for building observable, production ready,
distributed applications. .NET
.NET Aspire
Composition & Orchestration Components Tools
• Modeling language for
defining the system resources
and their dependencies
• A runtime to for running and
connecting multi-project
applications and their
dependencies
• Dashboard
• Distributed App VS support
• Service Defaults
• Publishing utils
• Packages of commonly used
services, such as Redis or
Postgres, with standardized
interfaces and capabilities
Orchestration Components Tools
Behind the
scenes
- 18. Standardizing how we use the system resources
• Each system resource our app depends on should be consumed by standardized
client
• The client should provide
– Observability and telemetry
> Logs
> Trace
> Metrics
– Health checks
– Resiliency - the ability of your system to react to failure and still remain functional
> Retries
> Timeouts
> Circuit breakers
• All the above should conform to the same conventions (configuration, API surface
etc) stated in
https://github.com/dotnet/aspire/blob/main/src/Components/README.md
Orchestration Components Tools
Behind the
scenes
- 19. Standardizing how we use the system resources
• Each system resource our app depends on should be consumed by standardized
client
• The client should provide
– Observability and telemetry
> Logs
> Trace
> Metrics
– Health checks
– Resiliency - the ability of your system to react to failure and still remain functional
> Retries
> Timeouts
> Circuit breakers
• All the above should conform to the same conventions (configuration, API surface
etc) stated in
https://github.com/dotnet/aspire/blob/main/src/Components/README.md
Orchestration Components Tools
Behind the
scenes
- 20. Standardizing how we use the system resources
• Each system resource our app depends on should be consumed by standardized
client
• The client should provide
– Observability and telemetry
> Logs
> Trace
> Metrics
– Health checks
– Resiliency - the ability of your system to react to failure and still remain functional
> Retries
> Timeouts
> Circuit breakers
• All the above should conform to the same conventions (configuration, API surface
etc) stated in
https://github.com/dotnet/aspire/blob/main/src/Components/README.md
Orchestration Components Tools
Behind the
scenes
- 24. Kafka as an example
dotnet add package Aspire.Confluent.Kafka
builder.AddKafkaProducer<string, string>(“purchase-events");
{
"ConnectionStrings": {
"purchase-events": “..."
},
"Aspire": {
"Confluent": {
"Kafka": {
"Producer": {
"HealthChecks": true,
"Config": {
"Acks": "All"
}
}
}
}
}
} appsettings.json
Orchestration Components Tools
Behind the
scenes
- 25. Kafka as an example
AppHost
Basket Service
Orchestration Components Tools
Behind the
scenes
- 26. .NET Aspire
Opinionated, cloud ready stack for building observable, production ready,
distributed applications. .NET
.NET Aspire
Composition & Orchestration Components Tools
• Modeling language for
defining the system resources
and their dependencies
• A runtime to for running and
connecting multi-project
applications and their
dependencies
• Dashboard
• Distributed App VS support
• Service Defaults
• Publishing utils
• Packages of commonly used
services, such as Redis or
Postgres, with standardized
interfaces and capabilities
Orchestration Components Tools
Behind the
scenes
- 28. Aspire Manifest
• Aspire project can generate a manifest that can later be used by other tools to
deploy into an environment
– Think of it as the IL for a distributed .NET app
dotnet run --project AspireApp.AppHost.csproj `
--publisher manifest
--output-path aspire-manifest.json
AspireHost
manifest.json
deploy tool
(azd/Aspir8)
provision
deploy
Orchestration Components Tools
Behind the
scenes
- 29. Aspire Manifest
• Aspire project can generate a manifest that can later be used by other tools to
deploy into an environment
– Think of it as the IL for a distributed .NET app
dotnet run --project AspireApp.AppHost.csproj `
--publisher manifest
--output-path aspire-manifest.json
Orchestration Components Tools
Behind the
scenes
- 31. Orchestration Components Tools
Behind the
scenes
Deploy the manifest to K8s or Compose with Aspir8
• https://github.com/prom3theu5/aspirational-manifests
dotnet tool install -g aspirate --prerelease
aspirate generate aspirate generate --output-format compose
Kustomize: Compose:
- 33. Service Defaults - Standardizing services behavior
• Every service enlisted with Aspire will get automatic reference and call to
– AddServiceDefaults()
– MapDefaultEndpoints() – if a web project
• Out of the box services gets these capabilities
– OpenTelemetry
– Default HealthChecks
– Service Discovery
– Standard Resiliency configuration for HttpClient
Orchestration Components Tools
Behind the
scenes
- 37. Behind the scenes &
Under the covers
Orchestration Components Tools
Behind the
scenes
- 49. Orchestration Components Tools
Behind the
scenes
Resource
Proxy
(traefik)
AspireHost
Visual Studio
DCP
(Developer
Control Plane)
Resource
Proxy
(traefik)
Create
resource
%TEMP%usvc-servicecontroller-serviceconfig]resource[.yaml
- 51. Orchestration Components Tools
Behind the
scenes
AspireHost
Visual Studio
DCP
(Developer
Control Plane)
Resource
Proxy
(traefik)
Create
resource
%TEMP%usvc-servicecontroller-serviceconfigresource.yaml
- 52. Orchestration Components Tools
Behind the
scenes
AspireHost
Visual Studio
DCP
(Developer
Control Plane)
Resource
Proxy
(traefik)
Create
resource
%TEMP%usvc-servicecontroller-serviceconfigresource.yaml
- 53. Orchestration Components Tools
Behind the
scenes
AspireHost
Visual Studio
DCP
(Developer
Control Plane)
Resource
Proxy
(traefik)
Create
resource
%TEMP%usvc-servicecontroller-serviceconfigresource.yaml
- 57. .NET Aspire - Summary
Opinionated, cloud ready stack for building observable, production ready,
distributed applications. .NET
.NET Aspire
Composition & Orchestration Components Tools
• Modeling language for
defining the system resources
and their dependencies
• A runtime to for running and
connecting multi-project
applications and their
dependencies
• Dashboard
• Distributed App VS support
• Service Defaults
• Publishing utils
• Packages of commonly used
services, such as Redis or
Postgres, with standardized
interfaces and capabilities