One of the recurring themes of recent developer platform and tool releases, especially around .NET, is developer productivity. That’s not surprising, considering the current economic climate and its impact on staffing levels. We’ve all been tasked to do more with less.
Microsoft and the .NET Foundation recently released the latest version of their cross-platform development framework, .NET 8. In advance of the launch, I sat down to talk with Gaurav Seth, partner director of product, developer platforms, at Microsoft, about the new release and about how he sees developers using .NET 8 in their day-to-day tasks.
Because .NET 8 is a Long Term Support release, it’s likely to be adopted by most .NET development teams, who will expect the platform to work well for them until the next LTS release, .NET 10. Like .NET 6 before it, .NET 8 mixes new features with improved tools, focusing on common delivery patterns and supporting new ways of working.
Deploying faster, with optimized containers
A key focus has been on infrastructure, especially around the rapidly growing cloud-native workloads. One area that I’ve touched on in previous articles is .NET’s container images. These have continued to be optimized, building on distro-less, chiseled images to speed up downloads and to increase the density of services on a host.
That last point is not one we typically think about, but it’s going to have a significant impact on both the scalability and cost of cloud-native applications. If you can use fewer resources to run an application with no effect on its performance, then you’re able to improve the economics of your code.
The numbers are impressive. A compressed, chiseled Ubuntu 22.04 image is now only 48MB, with a trimmed runtime of just 16MB. It’s small storage and memory footprint will allow you to speed up autoscaling of .NET resources in Kubernetes and try out new builds without waiting for images to download from your build system’s repository.
Making code more readable
One subtle effect of the new release is a set of improved language constructs that make C# code more readable. Simplifying code significantly improves maintainability, especially for large projects maintained by large development teams. An easier-to-parse syntax allows developers new to the code to understand it more quickly, reducing the time to a fix.
As Seth told me, “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 less lines of code that you have to write?” He describes it as a push to a minimal pattern, using the underlying platform to drive simplification in the languages it powers. For most of us, that means improvements in C#, but we’ll see aspects of these new features across the whole stable of .NET languages.
Opinionated cloud-native development
While much of the .NET 8 release has been public for some time now, through a series of release candidates and preview versions of Visual Studio, there’s still room for some surprises. This time it’s the unveiling of .NET Aspire, which Seth describes as an opinionated stack for building cloud-native applications with .NET.
You can think of .NET Aspire as a platform-level equivalent to tools like Dapr or Radius, giving you the scaffolding and guardrails necessary to build microservices-based applications on any public cloud. “It’s a golden paved path,” Seth told me. “It will come with a set of curated components and tooling, and supports resiliency, manageability, and observability.” Seth suggests that .NET Aspire aims to be for .NET what Spring Boot is for Java.
In any case, .NET Aspire starts to fill a big gap in .NET’s tools strategy. For a platform that’s used in many enterprise projects, it’s surprising that .NET doesn’t provide any enterprise-specific tooling or frameworks, leaving you to reinvent the wheel with every major project. With its ready-to-use opinionated approach, .NET Aspire should simplify life for many enterprise architects, allowing them to concentrate on delivering good code, fast.
A preview of .NET Aspire is shipping as part of the .NET 8 release, with a full release due in Spring 2024. The toolkit comes with a starter app that helps you stand up your first Aspire project and explore Aspire’s features. Along with .NET 8 you’ll need the latest Visual Studio preview release to build Aspire applications. There is basic support for the .NET CLI, and support for the C# Dev Kit for Visual Studio Code is planned.
Getting started with .NET Aspire
Creating your first .NET Aspire application gives you a front-end Blazor web app and a business logic service. Alongside these are two new project types, an AppHost and a set of ServiceDefaults. You can think of these as the orchestration engine for your .NET distributed applications.
The AppHost is where you define your application containers and other support tools, including connection strings, while ServiceDefaults hold all the service-centric features used for app discovery and for telemetry, so you have one place to connect your management and observability tools. These include OpenTelemetry endpoints and standard .NET health checks. ServiceDefaults also enable service discovery, so your APIs can be used by other components in your distributed environment.
The default templates provide the basic structure of a .NET Aspire application. You can use the two available starters to build your own apps, either using the standard sample to give you a foundation to build on, or using only the essentials and building your own front-end and back-end components from scratch.
One useful feature in the AppHost is the ability to quickly configure helper applications from your code, for example adding containers with databases and other application services. This approach allows your applications to self-orchestrate, using AppHost to manage Kubernetes and other infrastructure services for you. Components that describe infrastructure services are available through NuGet, so you can continue to use existing .NET tools, even while building out distributed application infrastructures.
The .NET Aspire component model is a powerful tool, and there are already components for most common Azure services, including third-party services like Redis and PostgreSQL. As the model is open source, you should expect to see additional services roll out quickly.
A developer dashboard for .NET
Unlike other parts of .NET, .NET Aspire has a developer dashboard. This is an important tool for distributed application development, as it gives you one place to see key metrics for your application, without having to leave your development environment to look at an observability suite or a monitoring platform (which are unlikely to be part of a development environment, anyway).
When you run your development code you get a visual trace of your requests, along with access to logs. This gives you the information needed to optimize calls, and track down the causes of slowdowns that might not be visible using conventional debugging tools—especially when you’re tracking a dependency on third-party tools like Redis.
One important benefit of using .NET Aspire is that, while it’s useful on its own, there’s the prospect of using it in synergy with other tools for building and running distributed applications. For example, what if your platform engineering team was building application infrastructures and definitions in Radius, with code being handled in .NET Aspire and deployments and sidecars in Dapr?
As .NET Aspire is an open-source platform, we can expect to see it evolve features that address other cloud-native scenarios beyond Azure. Considering AWS’s serverless platform hosts an active C# community, we could even see support for event-driven serverless applications, with tools that help configure target environments and that use code generation tools to provide native .NET implementations of service APIs.
With the launch of .NET Aspire and a whole host of other productivity tools, it’s clear that .NET 8 aims to make it quicker and easier to build the applications that both businesses and consumers need—including modern, distributed, cloud-native applications.
Copyright © 2023 IDG Communications, Inc.