Exploring Innovations in Microsoft’s .NET 8

Streamlined container images, simplified code syntax, and an unexpected addition—.NET Aspire, a curated framework for constructing cloud-native applications with .NET.

In the realm of recent developer platform and tool unveilings, particularly within the .NET ecosystem, a consistent focus emerges: developer productivity. Given the prevailing economic conditions and their impact on workforce capacity, the imperative to accomplish more with fewer resources is evident.

Microsoft and the .NET Foundation have recently introduced the latest iteration of their cross-platform development framework, .NET 8. In anticipation of the release, I engaged in a conversation with Gaurav Seth, Partner Director of Product, Developer Platforms, at Microsoft, delving into the new features and envisioning how developers might integrate .NET 8 into their daily workflows.

Given its status as a Long-Term Support release, .NET 8 is poised to garner widespread adoption among .NET development teams, expecting the platform to serve them effectively until the subsequent LTS release, .NET 10. Similar to its predecessor, .NET 6, .NET 8 combines novel features with enhanced tools, concentrating on common delivery patterns and supporting innovative work methodologies.

Expedited Deployment with Optimized Containers A paramount emphasis has been placed on infrastructure, particularly addressing the burgeoning landscape of cloud-native workloads. Notably, .NET’s container images have undergone continued optimization, evolving from distro-less, sculpted images to expedite downloads and bolster the density of services on a host.

While not immediately apparent, the impact on both the scalability and cost of cloud-native applications is substantial. By utilizing fewer resources to run an application without compromising performance, there is an enhancement in the economic efficiency of the code.

The statistics are noteworthy. A compressed, sculpted Ubuntu 22.04 image now stands at a mere 48MB, featuring a trimmed runtime of just 16MB. Its compact storage and memory footprint facilitate accelerated autoscaling of .NET resources in Kubernetes, enabling the exploration of new builds without waiting for images to download from the build system’s repository.

Enhancing Code Readability A subtle consequence of the latest release is a set of refined language constructs that enhance the readability of C# code. Streamlining code significantly contributes to maintainability, especially in extensive projects maintained by sizable development teams. An easily decipherable syntax allows developers, both seasoned and new, to comprehend the code swiftly, thus reducing the time required for troubleshooting.

As expressed by Seth, “And that’s the journey we’ve been on. How do we keep removing that boilerplate? How do we keep making it simpler and simpler and simpler and achieve a lot more with fewer lines of code that you have to write?” This push towards a minimal pattern utilizes the underlying platform to drive simplification across the array of .NET languages.

Opinionated Approach to Cloud-Native Development While much of the .NET 8 release has been in the public domain through various release candidates and preview versions of Visual Studio, there’s still room for surprises. In this instance, it’s the introduction of .NET Aspire, described by Seth as an opinionated stack for developing cloud-native applications with .NET.

Think of .NET Aspire as a platform-level equivalent to tools like Dapr or Radius, providing the necessary scaffolding and guardrails for constructing microservices-based applications across public clouds. Seth elaborates, “It’s a golden paved path. It will come with a set of curated components and tooling and supports resiliency, manageability, and observability.” .NET Aspire aspires to be for .NET what Spring Boot is for Java.

.NET Aspire fills a significant void in .NET’s tools strategy, particularly for enterprise projects. It’s surprising that .NET, widely employed in enterprise settings, lacks specific tooling or frameworks, necessitating reinvention with each major project. With its opinionated approach, .NET Aspire is poised to simplify the lives of enterprise architects, allowing them to focus on delivering high-quality code swiftly.

A preview of .NET Aspire ships as part of the .NET 8 release, with a full release anticipated in Spring 2024. The toolkit includes a starter app that facilitates the initiation of Aspire projects, offering a hands-on exploration of Aspire’s features. Alongside .NET 8, the latest Visual Studio preview release is necessary for building Aspire applications. Basic support for the .NET CLI is available, with plans for C# Dev Kit support for Visual Studio Code.

Embarking on .NET Aspire Initiating your inaugural .NET Aspire application sets the stage for a front-end Blazor web app and a business logic service. Accompanying these are two new project types: an AppHost and a set of ServiceDefaults. These serve as the orchestration engine for .NET distributed applications.

The AppHost is where you define application containers and auxiliary tools, such as connection strings. ServiceDefaults encompass service-centric features for app discovery and telemetry, consolidating management and observability tools in one place. OpenTelemetry endpoints and standard .NET health checks are included. ServiceDefaults also facilitate service discovery, enabling APIs for use by other components in a distributed environment.

Default templates outline the fundamental structure of a .NET Aspire application. Leveraging the available starters, you can construct your apps using either the standard sample for a foundational approach or the essentials-only option for building front-end and back-end components from scratch.

A notable feature in the AppHost is the swift configuration of helper applications directly from your code, adding containers with databases and other application services. This approach empowers your applications to self-orchestrate, utilizing AppHost to manage Kubernetes and other infrastructure services. NuGet provides components describing infrastructure services, ensuring compatibility with existing .NET tools while expanding distributed application infrastructures.

The .NET Aspire component model is potent, with existing components for prevalent Azure services, including third-party services like Redis and PostgreSQL. Being open source, additional services are expected to roll out rapidly.

Developer Dashboard for .NET Unlike other components of .NET, .NET Aspire introduces a developer dashboard—a vital tool for distributed application development. This consolidated space offers key metrics for your application without requiring a departure from your development environment to consult observability suites or monitoring platforms.

Running your development code provides a visual trace of requests and access to logs, furnishing essential information for optimizing calls and identifying performance bottlenecks not readily visible through conventional debugging tools—especially when tracking dependencies on third-party tools like Redis.

A noteworthy advantage of .NET Aspire is its potential synergy with other tools for building and running distributed applications. Imagine a scenario where your platform engineering team utilizes Radius to construct application infrastructures and definitions, while .NET Aspire handles the code and Dapr manages deployments and sidecars.

As an open-source platform, .NET Aspire is likely to evolve with features addressing various cloud-native scenarios beyond Azure. Considering the active C# community on AWS’s serverless platform, there’s potential for support in event-driven serverless applications. Tools facilitating target environment configuration and native .NET implementations of service APIs through code generation tools might be on the horizon.

With the introduction of .NET Aspire and an array of productivity tools, it’s evident that .NET 8 aims to expedite the development of applications crucial for both businesses and consumers. This includes modern, distributed, cloud-native applications.