Lädt...


🔧 (Azure App Service) Feature Flags in C#/Blazor App


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

This publication is part of the C# Advent Calendar 2024. Have a look at interesting articles about C# created by the community.

Feature flags, also known as feature toggles, are a powerful technique used in software development to enable or disable specific features or functionality within an application at runtime, without the need for redeployment. This practice is widely used for progressive rollouts, testing in production, A/B testing, and improving CI/CD workflows. Feature flags can also significantly enhance how features are delivered to users.

Feature flags are implemented in the code as conditional statements, allowing developers to control whether a particular feature is active or not, and also to decouple feature release from deployment. By wrapping a feature's code with a flag, you can control the behavior of the application without changing the underlying codebase, which results in greater flexibility and faster iterations.

Feature flags can be implemented in a variety of ways depending on your needs. They can be managed either through hardcoded values, configuration files, or external services such as Azure App Configuration, LaunchDarkly, or even your own backend.

Let's focus on a basic implementation of Feature Flags in a Blazor app. I will use Azure App Service configuration for this blog post.

Step 1. Set Up Azure App Configuration

You will need to create an Azure App Configuration instance and store your feature flags there.

Feature Flag Enabled

Step 2. Add Azure App Configuration Connection String

Retrieve the Connection String from your Azure resource:

Connection String

Add it to appsettings.json file in your Blazor project:

appsettings file

Step 3. Add the NuGet packages

Add the Microsoft.Azure.AppConfiguration.AspNetCore and Microsoft.FeatureManagement.AspNetCore NuGet packages to your project.

NuGet packages

Step 4. Modify Program.cs

Modify Program.cs to add the configuration provider and register the middleware and service:

Image description

Step 5. Use the Feature Flag in your code

For example, let's show/hide the Weather page from the menu:

First, use FeatureManager in your page to get the reference to the Feature Flag:

Image description

Secondly, show content based on the value.

Image description

Step 6. Let's test it.

Run the app and see the Weather option in the menu:

Image description

Now, let's disable the Feature Flag:

Image description

Now, refresh the website. No weather option is displayed this time:

Image description

As you can see, Feature Flags are easy to implement. Feature flags are an essential tool for managing application features in Blazor app. They provide flexibility in how features are rolled out, tested, and managed, enabling a more dynamic, reliable, and scalable way to deliver and manage features in production.

Remember to follow the rest of the interesting publications of the C# Advent Calendar 2024. You can also follow the conversation on Twitter with the hashtag #csadvent.

Thank you for reading. Until next time!
Luis

...

🪟 Blazor 8 vereint Blazor Server und Blazor WebAssembly | heise online


📈 46.41 Punkte
🪟 Windows Server

🔧 (Azure App Service) Feature Flags in C#/Blazor App


📈 45.93 Punkte
🔧 Programmierung

🔧 How to Add Blazor Components to a Blazor WPF App


📈 32.59 Punkte
🔧 Programmierung

🔧 Introducing Simple Blazor Grid: Lightweight Grid for Blazor Applications


📈 30.94 Punkte
🔧 Programmierung

🔧 Blazor #3 - How to Install Foundation into a Blazor Project


📈 30.94 Punkte
🔧 Programmierung

🔧 Blazor #3 - How to Install Foundation into a Blazor Project


📈 30.94 Punkte
🔧 Programmierung

🎥 Blazor Fundamentals Tutorial – Learn Blazor Step-by-Step


📈 30.94 Punkte
🎥 Video | Youtube

🔧 Blazor WebAssembly vs. Blazor Server: Which One Should You Choose?


📈 30.94 Punkte
🔧 Programmierung

📰 Blazor Server und Blazor WebAssembly: Alternativen zu JavaScript?


📈 30.94 Punkte
📰 IT Nachrichten

🔧 Welcome to Blazor | Focus on Blazor


📈 30.94 Punkte
🔧 Programmierung

📰 Blazor wird mobil: Microsoft stellt Mobile Blazor Bindings vor


📈 30.94 Punkte
📰 IT Nachrichten

📰 Blazor wird mobil: Microsoft stellt Mobile Blazor Bindings vor


📈 30.94 Punkte
📰 IT Nachrichten

🎥 Blazor in the cloud: Hosting a C# SPA app as a static website in Azure Storage | Azure Friday


📈 28.12 Punkte
🎥 Video | Youtube

🔧 Blazor in the cloud: Hosting a C# SPA app as a static website in Azure Storage | Azure Friday


📈 28.12 Punkte
🔧 Programmierung

🔧 Feature flags with .NET and Azure App Configuration | On .NET


📈 26.4 Punkte
🔧 Programmierung

🔧 Feature Flags in .NET 8 and Azure


📈 24.75 Punkte
🔧 Programmierung

🔧 Feature Flags in .NET 8 and Azure


📈 24.75 Punkte
🔧 Programmierung

🔧 Configuring a Server-side Blazor app with Azure App Configuration


📈 24.27 Punkte
🔧 Programmierung

🔧 Implementing Feature Flags with Spring: A Step-by-Step Guide for Feature Deployment


📈 24.23 Punkte
🔧 Programmierung

🔧 KeyMash, type your ways to feature with DevCycle feature flags


📈 24.23 Punkte
🔧 Programmierung

🔧 ️️🚀 🚀 Feature Flags 101: 3 Basic Feature Flag Use Cases You Can Implement Today 🏁


📈 24.23 Punkte
🔧 Programmierung

🔧 Build Scalable Blazor CRUD Apps in 30 Minutes with Azure SQL


📈 20.97 Punkte
🔧 Programmierung

🔧 Building Serverless web applications with Blazor and Azure Functions | On .NET


📈 20.97 Punkte
🔧 Programmierung

🔧 Blazor and Azure Functions for Serverless Websites


📈 20.97 Punkte
🔧 Programmierung

🔧 Leveraging Feature Flags With IBM Cloud App Configuration in React Applications


📈 20.9 Punkte
🔧 Programmierung

🔧 Leveraging Feature Flags With IBM Cloud App Configuration in React Applications


📈 20.9 Punkte
🔧 Programmierung

🔧 Implementing Feature Flags with Next.js and App Router


📈 20.9 Punkte
🔧 Programmierung

🎥 Azure Friday Live - Azure App Service full-screen create experience | Azure Friday


📈 20.56 Punkte
🎥 Video | Youtube

🎥 Azure Container Registry Tasks: Build and deploy to Azure App Service | Azure Friday


📈 20.56 Punkte
🎥 Video | Youtube

🔧 The Hidden Costs of Skipping Feature Flags: A QA Nightmare Tale from AWS 🐛


📈 19.25 Punkte
🔧 Programmierung

🔧 A guide to feature flags in Laravel using Laravel Pennant


📈 19.25 Punkte
🔧 Programmierung

🔧 Microservices Testing: Feature Flags vs. Preview Environments


📈 19.25 Punkte
🔧 Programmierung

🔧 How to Easily Use Feature Flags in Swift with Firebase


📈 19.25 Punkte
🔧 Programmierung

🔧 Feature Flags and Canary Releases in Microservices


📈 19.25 Punkte
🔧 Programmierung

matomo