.NET Feature Management Powered by a Rest API

Ben
6 min readJul 18, 2023
Photo by Yancy Min on Unsplash

Microsoft has a pretty good feature management system available to use in most .NET applications. It’s based around IConfiguration and it’s quick to set up with a JSON file to manage feature flags.

It has some pretty nice features like setting a feature to be enabled based on a time window, it can be configured based on a percentage, and then you have the basic on/off switch mode.

Now, I don’t really have a need for anything fancy. I would, however, like to be able to pull in my feature flags from a database. I need to go through a Rest API in order to access that data due to some project restrictions. So let me show you what I did to get that working.

Just want the code?

Here is a GitHub repository with the code from this article.

https://github.com/BenBurge/Medium.Articles.FeatureFlags

The Setup

  • Using .NET 7
  • Using Microsoft.EntityFrameworkCore
  • Postgres DB and the accompanying Nuget package Npgsql.EntityFrameworkCore.PostgreSQL
  • Using the Microsoft.FeatureManagement Nuget package
  • A basic API project
  • A basic console application

--

--