What Is .NET Aspire? The Insane Future of .NET!

What Is .NET Aspire? The Insane Future of .NET!

Introduction to net Aspire

In this section, Nick introduces net Aspire, a cloud-ready stack for building observable production-ready distributed applications. He explains that net Aspire is unique as it was developed privately by Microsoft and aims to solve pain points in building distributed and cloud-native apps.

What is net Aspire?

  • Net Aspire is an opinionated cloud-ready stack for building observable production-ready distributed applications.
  • It solves pain points in building distributed and cloud-native apps.
  • It allows easy implementation and communication between services.

Similarities with Project Tye

  • Net Aspire shares similarities with Project Tye, an experiment from Microsoft.
  • Learnings from Project Tye influenced the development of net Aspire.
  • However, net Aspire focuses on the development aspect without deployment features.

Simplifying Communication Between Services

In this section, Nick explains how net Aspire simplifies communication between services in distributed applications. He highlights that it should be easy to connect different components such as databases, caches, and apps within a distributed app.

Pain Points in Distributed Applications

  • Distributed applications often consist of many small apps or components.
  • Connecting these components can be challenging during development and deployment.
  • Net Aspire aims to solve these challenges by providing easy communication between services.

Example Demonstration of Using net Aspire

In this section, Nick demonstrates how to use net Aspire through a simple example. He showcases a weather app consisting of a Blazor web application and an API. The web app communicates with the API to retrieve weather data.

Weather App Example

  • The example includes a weather app web (Blazor) and weather app API.
  • The web app retrieves weather data from the API.
  • Communication between the web app and API is facilitated by net Aspire.

Discount on doet tr.com Courses

In this section, Nick announces a Black Friday discount on doet tr.com courses. He encourages viewers to take advantage of the discount to enhance their learning as .NET developers.

Black Friday Discount

  • A Black Friday discount is available on doet tr.com courses.
  • Viewers can use the code "BlackFriday23" for 40% off any course and 20% off discounted bundles.
  • The discount is valid until November 27th.

Configuring the Weather App Example

In this section, Nick explains how the weather app example is configured. He mentions a weather API client that calls an endpoint to retrieve weather forecast data. The client is injected into the web app's pages to display the weather information.

Configuration of Weather App Example

  • The weather app example includes a weather API client that retrieves weather forecast data.
  • The client is injected into the web app's pages to display the weather information.
  • Configuration details can be found in program.cs file.

Flexibility in Configuring net Aspire

In this section, Nick discusses flexibility in configuring net Aspire. He mentions that while he keeps the configuration simple in his demonstration, it is possible to load configuration settings from app settings files for different environments (development, production, staging).

Configuring net Aspire

  • Net Aspire allows flexibility in configuration settings.
  • Configuration can be kept simple or loaded from app settings files for different environments.
  • Different configurations can be used for development, production, staging, etc.

Challenges in Locating Services

In this section, Nick highlights the challenges of locating services when multiple services are running locally. He emphasizes that net Aspire helps address this challenge by simplifying service communication.

Challenges in Locating Services

  • When multiple services are running locally, it can be difficult to locate and communicate with them.
  • Net Aspire simplifies service communication, making it easier to connect different components.

The above summary covers the main points discussed in the transcript. Some parts of the transcript may not have been included if they were not relevant or did not provide additional information.

Aspire: Changing the Way Apps Run Together as a System

In this section, the speaker introduces Aspire and explains how it aims to solve issues related to app synchronization and debugging in a system. The speaker also mentions that Aspire can be installed using Visual Studio or through the CLI.

Introducing Aspire

  • Aspire is designed to change the way apps run together as a system, addressing issues of synchronization and potential breaks.
  • Debugging a system with multiple apps currently requires debugging each component separately (API, web, etc.), but Aspire aims to simplify this process.

Installing Aspire

  • Aspire can be installed using Visual Studio or through the CLI.
  • To install without Visual Studio, use dotnet workload update followed by dotnet workload install Aspire.
  • In Visual Studio, modify the installation and choose "Aspire SDK" to install necessary templates.

Creating an Aspire Project

  • In Visual Studio, add a new project and search for "Aspire".
  • Choose "ASP.NET Core Web Application" template for creating an Aspire project.
  • Specify a name for the project (e.g., Weather App) and select .NET 8 as the target framework.
  • By default, two projects are created: AppHost (for running the distributed system) and ServiceDefaults (configuring defaults for Aspire).

Using VS Tooling for Configuration

  • VS tooling simplifies configuration by adding references and configuring defaults automatically.
  • Right-click on the web project (Blazor app), select "Add Aspire Orchestrator Support", and choose to use existing orchestration from AppHost.
  • Similarly, add orchestrator support to the API project.

Manual Configuration in Rider

  • Configuration steps done with VS tooling can also be done manually in Rider IDE.
  • Add references between projects manually (e.g., referencing the API project in the web project).
  • Ensure proper wiring up of projects to make them aware of each other.

Exploring Aspire Host and Service Defaults

In this section, the speaker explains the changes made to the project structure after adding Aspire support. The AppHost project becomes a distributed application, and the ServiceDefaults project configures default settings for Aspire. The speaker also mentions additional configuration options available.

Changes in Project Structure

  • After adding Aspire support, the AppHost project becomes a distributed application.
  • The type of the AppHost project is now an SDK-based Microsoft.NET.SDK project with Aspire hosting enabled.
  • The web app's Program.cs file includes an AddServiceDefaults call to configure default services for Aspire.

Additional Configuration Options

  • The ServiceDefaults class in the ServiceDefaults project contains configurations that can be modified as needed.
  • The MapDefaultEndpoints method at the bottom of Program.cs sets up endpoints required for Aspire orchestration.

Manual Configuration in Rider and Conclusion

In this final section, the speaker demonstrates manual configuration steps in Rider IDE and concludes by highlighting that Aspire works seamlessly across different IDEs without being specific to Visual Studio.

Manual Configuration in Rider

  • All configuration steps done using VS tooling can also be performed manually in Rider IDE.
  • References between projects can be added manually to establish communication.
  • Wiring up projects ensures awareness of each other's existence.

Seamless Integration Across IDEs

  • Aspire is not limited to Visual Studio; it works seamlessly across different IDEs like Rider.
  • Tooling provided by IDEs is complementary, and everything is driven by references and NuGet packages.

Timestamps are approximate and may vary slightly depending on video playback.

Understanding the App Host and Magic of Configuration

In this section, the speaker explains how the app host works and its role in running a distributed application. They also mention that the magic behind it is based on configuration frameworks and environment variables.

App Host and Running a Distributed Application

  • The app host allows running a whole distributed application without needing to know specific addresses or locations of individual components.
  • The configuration framework and environment variables play a crucial role in making this magic happen.

Exploring the Aspire Dashboard

Here, the speaker demonstrates the Aspire dashboard, which provides an overview of the front end, API, environment variables, logs, containers, executables, structured logs, traces, and metrics.

Features of the Aspire Dashboard

  • The Aspire dashboard displays information about the front end and API.
  • It allows running endpoints for both applications.
  • Environment variables are loaded from the framework (e.g., Open Telemetry).
  • Real-time logs can be viewed for each application.
  • Console access is available within the dashboard.
  • Containers can be managed through this interface.
  • Structured logs provide detailed information about requests.
  • Traces show how much time each request took to process.
  • Metrics offer insights into various aspects of application performance.

Leveraging Open Telemetry for Observability

This section highlights how open telemetry is used by default to instrument applications for observability. It enables features like tracing requests and viewing metrics related to app usage.

Benefits of Open Telemetry Integration

  • Applications instrumented with open telemetry support standard observability features.
  • Traces provide details about request durations for different components.
  • Metrics allow tracking various aspects such as JIT compilation time and garbage collector behavior.
  • Observability and tracking are available without manual configuration changes.
  • Open telemetry follows open standards, making it compatible with different types of apps.

Adding Output Caching with Redis

The speaker explains how to add output caching to the weather view using Redis as a distributed caching solution. They demonstrate the process of configuring Redis in a container and integrating it into the application.

Implementing Output Caching with Redis

  • To enable output caching, the speaker adds a Redis container to the app host.
  • The Aspire project provides built-in support for Redis as a distributed caching solution.
  • The speaker installs the Microsoft-maintained Aspire.Redis package via NuGet.
  • Configuration code is added in program.cs to wire up and use the output caching feature.
  • After mapping endpoints, the "use output cache" middleware is applied to introduce caching to specific pages or views.
  • The weather page is decorated with an attribute specifying a 5-second duration for caching on Redis.

Running App Host with Redis Container

In this section, the speaker demonstrates running the app host along with a Docker container for Redis. They show how the dashboard now includes information about both front end, weather API, and the newly added Redis cache container.

Running App Host with Redis Container

  • By running the app host, not only do individual apps start but also a Docker container for Redis starts automatically.
  • The dashboard now shows all three components - front end, weather API, and Redis cache - consolidated into one view.

Overview of Observability Stack

In this section, the speaker discusses the observability stack in Aspire, including weather forecast API calls and setting values in containers.

Observability Stack Features

  • The speaker mentions that the observability stack in Aspire includes containers and reddits (possibly referring to Redis).
  • The weather forecast API is used to retrieve weather information.
  • A value called "X" is set in the "reddish" container.

Customization and Request Tracking

The speaker explains how customization can be done in Aspire and demonstrates request tracking.

Customization Options

  • Aspire allows for customization of various aspects.
  • The speaker mentions that they can prove that no requests are going to the weather API, as all requests are directed to "redish."
  • A GET request is shown happening quickly, indicating efficient performance.

Deployment of an Application

This section focuses on deploying an application using Aspire.

Deployment Process

  • Microsoft has provided a way to consume how an app comes together without specifying how it should be deployed.
  • To deploy an application with Aspire:
  • Navigate to the apphost directory.
  • Run netrun publisher command with the Manifest option.
  • Specify manifest.json as the output path for generating a manifest file.

Flexibility in Deployment Approach

The speaker highlights Microsoft's approach of not dealing with deployment specifics in Aspire.

Approach to Deployment

  • Microsoft acknowledges that different users have different ways of deploying applications.
  • Instead of dictating a specific deployment method, Microsoft provides a way for users to consume and customize their app's deployment process.
  • The generated manifest.json file describes the application's resources, including the Redd cache and weather API.

High-Level Configuration

The speaker emphasizes the flexibility and customization options available in Aspire.

Customization and Configuration

  • Aspire offers a high level of configurability.
  • Users can tap into and modify various aspects of the project according to their needs.
  • The speaker mentions that there are many more features of Aspire that haven't been shown yet.

Manifest File Details

This section provides an overview of the contents of the generated manifest.json file.

Contents of Manifest File

  • The manifest.json file includes:
  • Resources such as Redd cache and weather API.
  • Paths for accessing necessary files like Cs Pro.
  • Open telemetry configuration as environment variables.
  • Bindings, schemes, front-end details, and HTTP weather API bindings (environment variables).

Conclusion and Future Outlook

The speaker concludes by expressing enthusiasm for Aspire's potential and invites viewers to subscribe for more content.

Final Thoughts

  • The speaker finds Aspire to be an amazing project with immense potential.
  • There are many additional features that haven't been covered in this showcase.
  • Microsoft's continued development of Aspire is anticipated, with a bright future ahead.
Video description

Use code BLACKFRIDAY23 and get 40% off any course and 20% off any bundle on Dometrain: https://dometrain.com/courses?coupon_code=BLACKFRIDAY23 Get the source code: https://mailchi.mp/dometrain/ns9vo74scv Become a Patreon and get special perks: https://www.patreon.com/nickchapsas Hello everybody, I'm Nick, and in this video, I will showcase .NET Aspire, which was announced in .NET 8's .NET Conf. It is a fantastic stack for building cloud-native distributed applications, and there is a lot to cover, so let's jump into it. Workshops: https://bit.ly/nickworkshops Don't forget to comment, like and subscribe :) Social Media: Follow me on GitHub: https://github.com/Elfocrash Follow me on Twitter: https://twitter.com/nickchapsas Connect on LinkedIn: https://www.linkedin.com/in/nick-chapsas Keep coding merch: https://keepcoding.shop #csharp #dotnet #dotnetconf