Indiko.Blocks.API.FeatureManagement
2.1.3
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Indiko.Blocks.API.FeatureManagement --version 2.1.3
NuGet\Install-Package Indiko.Blocks.API.FeatureManagement -Version 2.1.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Indiko.Blocks.API.FeatureManagement" Version="2.1.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Indiko.Blocks.API.FeatureManagement" Version="2.1.3" />
<PackageReference Include="Indiko.Blocks.API.FeatureManagement" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Indiko.Blocks.API.FeatureManagement --version 2.1.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Indiko.Blocks.API.FeatureManagement, 2.1.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Indiko.Blocks.API.FeatureManagement@2.1.3
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Indiko.Blocks.API.FeatureManagement&version=2.1.3
#tool nuget:?package=Indiko.Blocks.API.FeatureManagement&version=2.1.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Indiko.Blocks.API.FeatureManagement
Feature flag management block for controlling feature rollouts, A/B testing, and gradual deployments using Microsoft Feature Management.
Overview
This package provides feature flag (feature toggle) support for ASP.NET Core APIs, enabling dynamic feature control without code deployments.
Features
- Feature Flags: Enable/disable features dynamically
- Conditional Features: Context-based feature activation
- A/B Testing: Percentage-based feature rollouts
- Targeting: User/group-specific features
- Time Windows: Schedule feature availability
- MVC Integration: Feature-aware controllers and actions
- IFeatureManager: Programmatic feature checks
- Configuration-Based: Define features in appsettings.json
Installation
dotnet add package Indiko.Blocks.API.FeatureManagement
Quick Start
Configuration (appsettings.json)
{
"FeatureManagement": {
"NewUserInterface": true,
"BetaFeatures": false,
"PremiumFeatures": {
"EnabledFor": [
{
"Name": "Percentage",
"Parameters": {
"Value": 50
}
}
]
}
}
}
Basic Usage
Check Features in Code
using Microsoft.FeatureManagement;
public class ProductsController : ControllerBase
{
private readonly IFeatureManager _featureManager;
public ProductsController(IFeatureManager featureManager)
{
_featureManager = featureManager;
}
[HttpGet]
public async Task<IActionResult> GetProducts()
{
if (await _featureManager.IsEnabledAsync("NewUserInterface"))
{
return Ok(await GetProductsWithNewUI());
}
return Ok(await GetProductsWithOldUI());
}
}
Feature Gates on Actions
using Microsoft.FeatureManagement.Mvc;
[ApiController]
[Route("api/[controller]")]
public class BetaController : ControllerBase
{
[HttpGet]
[FeatureGate("BetaFeatures")] // Only accessible if BetaFeatures is enabled
public IActionResult GetBetaFeature()
{
return Ok("Beta feature data");
}
}
Feature Types
Simple Boolean Flags
{
"FeatureManagement": {
"DarkMode": true,
"MaintenanceMode": false
}
}
if (await _featureManager.IsEnabledAsync("DarkMode"))
{
// Apply dark mode
}
Percentage Rollout (A/B Testing)
{
"FeatureManagement": {
"NewCheckout": {
"EnabledFor": [
{
"Name": "Percentage",
"Parameters": {
"Value": 25 // 25% of users see new checkout
}
}
]
}
}
}
Time Window Features
{
"FeatureManagement": {
"HolidaySale": {
"EnabledFor": [
{
"Name": "TimeWindow",
"Parameters": {
"Start": "2024-12-20T00:00:00Z",
"End": "2024-12-26T23:59:59Z"
}
}
]
}
}
}
User Targeting
{
"FeatureManagement": {
"PremiumFeatures": {
"EnabledFor": [
{
"Name": "TargetingFilter",
"Parameters": {
"Audience": {
"Users": [
"user1@example.com",
"user2@example.com"
],
"Groups": [
"premium",
"beta-testers"
]
}
}
}
]
}
}
}
Feature Filters
Built-in Filters
- Percentage Filter: Gradual rollout based on percentage
- Time Window Filter: Time-based activation
- Targeting Filter: User/group-based activation
Custom Feature Filter
using Microsoft.FeatureManagement;
[FilterAlias("Environment")]
public class EnvironmentFeatureFilter : IFeatureFilter
{
private readonly IWebHostEnvironment _environment;
public EnvironmentFeatureFilter(IWebHostEnvironment environment)
{
_environment = environment;
}
public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context)
{
var settings = context.Parameters.Get<EnvironmentFilterSettings>();
return Task.FromResult(settings.Environments.Contains(_environment.EnvironmentName));
}
}
public class EnvironmentFilterSettings
{
public string[] Environments { get; set; }
}
// Register
services.AddFeatureManagement()
.AddFeatureFilter<EnvironmentFeatureFilter>();
// Use in config
{
"FeatureManagement": {
"DebugTools": {
"EnabledFor": [
{
"Name": "Environment",
"Parameters": {
"Environments": ["Development", "Staging"]
}
}
]
}
}
}
Controller-Level Gates
[ApiController]
[Route("api/[controller]")]
[FeatureGate("AdminPanel")] // Entire controller requires feature
public class AdminController : ControllerBase
{
[HttpGet("users")]
public IActionResult GetUsers() => Ok(users);
[HttpGet("settings")]
[FeatureGate("AdvancedSettings")] // Additional feature requirement
public IActionResult GetSettings() => Ok(settings);
}
Middleware Integration
public class FeatureCheckMiddleware
{
private readonly RequestDelegate _next;
private readonly IFeatureManager _featureManager;
public FeatureCheckMiddleware(RequestDelegate next, IFeatureManager featureManager)
{
_next = next;
_featureManager = featureManager;
}
public async Task InvokeAsync(HttpContext context)
{
if (context.Request.Path.StartsWithSegments("/api/beta"))
{
if (!await _featureManager.IsEnabledAsync("BetaAccess"))
{
context.Response.StatusCode = 403;
await context.Response.WriteAsync("Beta access not available");
return;
}
}
await _next(context);
}
}
Service Layer
public class ProductService
{
private readonly IFeatureManager _featureManager;
private readonly IProductRepository _repository;
public async Task<ProductDto> GetProductAsync(Guid id)
{
var product = await _repository.ReadByIdAsync(id);
if (await _featureManager.IsEnabledAsync("EnhancedProductDetails"))
{
product.AdditionalDetails = await LoadEnhancedDetails(id);
}
return product;
}
}
Configuration Sources
AppSettings
{
"FeatureManagement": {
"Feature1": true
}
}
Environment Variables
export FeatureManagement__Feature1=true
Azure App Configuration
services.AddAzureAppConfiguration(options =>
{
options.Connect(connectionString)
.UseFeatureFlags();
});
Best Practices
- Naming: Use descriptive names (NewCheckoutFlow, EnhancedSearch)
- Cleanup: Remove feature flags once fully rolled out
- Testing: Test both enabled and disabled states
- Documentation: Document what each feature flag controls
- Monitoring: Track feature usage and performance
- Gradual Rollout: Start with small percentages
- Fallbacks: Always have fallback logic
Deployment Strategies
Canary Deployment
{
"FeatureManagement": {
"NewPaymentGateway": {
"EnabledFor": [
{
"Name": "Percentage",
"Parameters": { "Value": 5 } // Start with 5%
}
]
}
}
}
Monitor, then increase: 5% ? 25% ? 50% ? 100%
Blue-Green Deployment
{
"FeatureManagement": {
"UseNewDatabase": false // Toggle between old/new
}
}
Testing
Unit Testing
[Fact]
public async Task GetProducts_WithNewUI_ReturnsEnhancedData()
{
// Arrange
var featureManagerMock = new Mock<IFeatureManager>();
featureManagerMock
.Setup(x => x.IsEnabledAsync("NewUserInterface", It.IsAny<CancellationToken>()))
.ReturnsAsync(true);
var controller = new ProductsController(featureManagerMock.Object);
// Act
var result = await controller.GetProducts();
// Assert
Assert.IsType<OkObjectResult>(result);
}
Target Framework
- .NET 10
Dependencies
Microsoft.FeatureManagement.AspNetCore(3.0+)Indiko.Blocks.Common.Abstractions
License
See LICENSE file in the repository root.
Related Packages
Indiko.Blocks.API.Swagger- API documentationIndiko.Blocks.API.Compression- Response compressionMicrosoft.FeatureManagement- Core feature managementMicrosoft.FeatureManagement.AspNetCore- ASP.NET Core integration
Resources
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Indiko.Blocks.Common.Abstractions (>= 2.1.3)
- Microsoft.Data.SqlClient (>= 7.0.0-preview3.25342.7)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.1)
- Microsoft.FeatureManagement.AspNetCore (>= 4.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.1.4 | 3 | 3/2/2026 |
| 2.1.3 | 38 | 2/27/2026 |
| 2.1.2 | 248 | 12/18/2025 |
| 2.1.1 | 640 | 12/2/2025 |
| 2.1.0 | 627 | 12/2/2025 |
| 2.0.0 | 294 | 9/17/2025 |
| 1.7.23 | 197 | 9/8/2025 |
| 1.7.22 | 183 | 9/8/2025 |
| 1.7.21 | 201 | 8/14/2025 |
| 1.7.20 | 198 | 6/23/2025 |
| 1.7.19 | 199 | 6/3/2025 |
| 1.7.18 | 195 | 5/29/2025 |
| 1.7.17 | 192 | 5/26/2025 |
| 1.7.15 | 147 | 4/12/2025 |
| 1.7.14 | 169 | 4/11/2025 |
| 1.7.13 | 168 | 3/29/2025 |
| 1.7.12 | 181 | 3/28/2025 |
| 1.7.11 | 179 | 3/28/2025 |
| 1.7.10 | 183 | 3/28/2025 |
| 1.7.9 | 176 | 3/28/2025 |
Loading failed