The .NET Stacks #3: Native feature flags, local Kubernetes, community roundup!

Let's talk feature flags and Kubernetes in Visual Studio.

Dave Brock
Dave Brock

This is an archive of my weekly (free!) newsletter, The .NET Stacks. Consider subscribing today to get this content right away! Subscribers don’t have to wait a week to receive the content.

In this week’s issue we will be talking about:

  • Native .NET feature flags
  • Working with Kubernetes clusters locally in Visual Studio
  • Community roundup

Native .NET feature flags

Have you implemented feature flags (or feature toggles) in your applications? They’re a great way to easily enable and disable system features and behaviors without changing code. They can generate complexity if not managed well, but the benefits are great when it comes to A/B testing, gradual rollouts, and managing long-living branches. Martin Fowler has a good language-agnostic overview on the topic.

Until somewhat recently, to get this capability in .NET you had to either roll your own solution or depend on an external library such as LaunchDarkly and Esquio. You can now use native Microsoft libraries to accomplish much of this functionality. Microsoft provides the Microsoft.FeatureManagement library (supported by .NET Standard 2.0, meaning compatibility with .NET Framework!) and Microsoft.FeatureManagement.AspNetCore. I’ve noticed a lot of folks in the community are writing about it (including yours truly!), as it’s easy to use and has a pretty solid feature set. The external libraries still hold value with their advanced functionality and support but if you need something to accomplish most of what you need, all on top of ASP.NET configuration, you’ve got it

The libraries are open-sourced, where you can see much of the benefits:

  • Pre-packaged feature filters, and the ability to write your own with the IFeatureManager interface
  • Easy service registration in ASP.NET Core middleware
  • Ability to gate features at the controller/action level with FeatureGate
  • Support for a <feature> tag helper to get away from the @if Razor syntax and to assist with conditional rendering
  • HttpContext support
  • Ability to execute flags if a set of flags are specified, and the ability to check for missing feature filters For details, check out the docs.

New Visual Studio feature: Local Process with Kubernetes

Microsoft rolled out a new preview of Visual Studio 2019 this week (16.7 Preview 2, to be exact - if you aren’t aware, you can install these with regular Visual Studio side-by-side). It’s easy to gloss over another preview, but the VS team has introduced a new feature feature: Local Process with Kubernetes.

Kubernetes, love it as we might, is Latin for “overly complicated.” (It’s true, you don’t need to Google it.) Even if you have a solid workflow down, it involves updating your source code, building a container image, and deploying to your cluster - and forcing you to manage Dockerfile and Kubernetes manifest files. If you have a lot of microservices, each with their own data stores, it’s a real, actual headache.

Using Local Process with Kubernetes, you connect your machine to your Kubernetes cluster and don’t need to compile all your dependencies every single time. Environment variables, connection strings, and the like are inherited by the local microservice code. Under the covers, the feature redirects traffic between your connected cluster and your development machine.

It looks promising. If you try it out, let me know how it goes (you can reply to this email, or the Twitter links are below).

(You can also use this feature in Visual Studio Code.)

Odds and ends

Authentication and security is not easy, and a pain point for those with simple scenarios in ASP.NET Core. It is designed to be standard-based, but the learning curve is real. The community is listening.

Need a Blazor fix? Register for Blazor Day on June 18.

Community roundup

From Microsoft

Blog posts

Podcasts/videos

New subscribers and feedback

Has this email been forwarded to you? Welcome! I’d love for you to subscribe and join the community. I promise to guard your email address with my life.

I would love to hear any feedback you have for The .NET Stacks! My goal is to make this the one-stop shop for weekly updates on developing in the .NET ecosystem, so I look forward to any feedback you can provide. You can directly reply to this email, or talk to me on Twitter as well. See you next week!

.NET Stacks