Skip links
.net aspire

Transforming .NET Development: Microsoft Introduces .NET Aspire

Microsoft just made.NET Aspire, their new cloud-native development platform, generally available.

Build observable, production-ready distributed apps with built-in resiliency, manageability, and observability with ASP NET Aspire, a complete stack. Cloud-native application development is simplified with the help of.NET Aspire, which provides a developer dashboard and a selection of carefully chosen components and tools.

At its Build developer conference, Microsoft introduced .NET Aspire as a free, open-source, and cloud-agnostic platform for building cloud-native applications with proven tools. Developers can start using .NET Aspire in Visual Studio 2022 17.10, the .NET CLI, or Visual Studio Code.

In this blog post let’s have a closer look at .NET Aspire.

What is .NET Aspire?

.NET Aspire is a specialized, cloud-ready stack designed for building observable, production-ready distributed applications. It is delivered through a collection of NuGet packages that address specific cloud-native concerns.

Cloud-native software, in contrast to traditional monolithic apps, usually consist of tiny, interconnected parts, or microservices. These applications frequently make use of a variety of services, such as caching solutions, messaging systems, and databases.

Why Choose .NET Aspire?

.NET Aspire is crafted to enhance the process of building .NET cloud-native applications. It offers a cohesive, opinionated set of tools and patterns that streamline the development and operation of distributed applications. Here’s how .NET Aspire can assist you:

  • Orchestration: .NET Aspire includes features for orchestrating and connecting multi-project applications and their dependencies within local development environments.
  • Components: .NET Aspire components are NuGet packages that encapsulate commonly used services, such as Redis or Postgres, with standardized interfaces, ensuring seamless integration with your application.
  • Tooling: .NET Aspire provides project templates and tooling experiences for Visual Studio, Visual Studio Code, and the dotnet CLI, enabling you to efficiently create and manage .NET Aspire projects.

.NET Aspire Components

.NET Aspire components are NuGet packages designed to simplify connections to popular services and platforms, such as Redis or PostgreSQL. They address many cloud-native concerns through standardized configuration patterns, such as adding health checks and telemetry.

Each component is integrated with .NET Aspire orchestration, and their configurations are automatically injected by referencing named resources. For example, if Example.ServiceFoo references Example.ServiceBar, Example.ServiceFoo inherits the required configurations from the component, enabling seamless communication between them.

For instance, the AddAzureServiceBusClient method performs the following tasks:

builder.AddAzureServiceBusClient(“servicebus”);

  • Registers a ServiceBusClient as a singleton in the DI (Dependency Injection) container to connect to Azure Service Bus.
  • Applies ServiceBusClient configurations either through inline code or configuration.
  • Enables corresponding health checks, logging, and telemetry specific to the usage of Azure Service Bus.

You can find a comprehensive list of available components on the .NET Aspire components overview page.

Application Hosting

.NET Aspire introduces an App Host project, enabling developers to use C# and familiar APIs to describe and configure various application projects and hosted services within a distributed application.

The App Host project supports two execution modes:

  • Run: For local development.
  • Publish: For generating a manifest file to enhance deployment scenarios.

.NET Aspire includes hosting extensions for integrating Node.js applications, common container and cloud-based services, and supports the extension with custom hosting extensions.

Orchestration

In .NET Aspire, orchestration primarily enhances the local development experience by simplifying the management of configuration and interconnections within your cloud-native application. It’s important to note that .NET Aspire’s orchestration does not aim to replace robust production systems like Kubernetes. Instead, it provides abstractions that streamline the setup of service discovery, environment variables, and container configurations, abstracting away low-level implementation details. These abstractions ensure a consistent setup pattern across applications with multiple components and services, making it easier to manage complex applications during the development phase.

.NET Aspire orchestration addresses the following concerns:

  • App composition: Define the .NET projects, containers, executables, and cloud resources that comprise the application.
  • Service discovery and connection string management: The app host manages the injection of correct connection strings, network configurations, and service discovery information, simplifying the developer experience.

For instance, with .NET Aspire, you can create a local Redis container resource and configure the appropriate connection string in the “frontend” project using just two helper method calls.

// Create a distributed application builder given the command line arguments.
var builder = DistributedApplication.CreateBuilder(args);

// Add a Redis server to the application.
var cache = builder.AddRedis(“cache”);

// Add the frontend project to the application and configure it to use the
// Redis server, defined as a referenced dependency.
builder.AddProject<Projects.MyFrontend>(“frontend”)
.WithReference(cache);

Check-out NET Aspire orchestration overview for more information.

Share your views and feedback on .NET Aspire!

Stay tuned as we explore these exciting developments in greater detail in future posts!