Skip to content

Commit e5ac98a

Browse files
authored
Merge pull request #263120 from maud-lv/ml-flagfilters
Refresh Use feature filters
2 parents cecaf53 + 9ce78eb commit e5ac98a

10 files changed

+25
-26
lines changed

articles/azure-app-configuration/howto-feature-filters-aspnet-core.md

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
---
22
title: Use feature filters to enable conditional feature flags
33
titleSuffix: Azure App Configuration
4-
description: Learn how to use feature filters to enable conditional feature flags
4+
description: Learn how to use feature filters in Azure App Configuration to enable conditional feature flags for your app.
55
ms.service: azure-app-configuration
66
ms.devlang: csharp
77
ms.custom: devx-track-csharp
88
author: maud-lv
99
ms.author: malev
10-
ms.topic: conceptual
11-
ms.date: 3/9/2020
10+
ms.topic: how-to
11+
ms.date: 01/12/2024
12+
#Customerintent: As a developer, I want to create a feature filter to activate a feature flag depending on a specific scenario.
1213
---
14+
1315
# Use feature filters to enable conditional feature flags
1416

1517
Feature flags allow you to activate or deactivate functionality in your application. A simple feature flag is either on or off. The application always behaves the same way. For example, you could roll out a new feature behind a feature flag. When the feature flag is enabled, all users see the new feature. Disabling the feature flag hides the new feature.
@@ -24,7 +26,11 @@ The `Microsoft.FeatureManagement` library includes three feature filters:
2426

2527
You can also create your own feature filter that implements the Microsoft.FeatureManagement.IFeatureFilter interface.
2628

27-
## Registering a feature filter
29+
## Prerequisites
30+
31+
- An App Configuration store. [Create a store](./quickstart-azure-app-configuration-create.md#create-an-app-configuration-store).
32+
33+
## Register a feature filter
2834

2935
You register a feature filter by calling the `AddFeatureFilter` method, specifying the type name of the desired feature filter. For example, the following code registers `PercentageFilter`:
3036

@@ -36,51 +42,44 @@ public void ConfigureServices(IServiceCollection services)
3642
}
3743
```
3844

39-
## Configuring a feature filter in Azure App Configuration
45+
## Configure a feature filter in Azure App Configuration
4046

4147
Some feature filters have additional settings. For example, `PercentageFilter` activates a feature based on a percentage. It has a setting defining the percentage to use.
4248

4349
You can configure these settings for feature flags defined in Azure App Configuration. For example, follow these steps to use `PercentageFilter` to enable the feature flag for 50% of requests to a web app:
4450

4551
1. Follow the instructions in [Quickstart: Add feature flags to an ASP.NET Core app](./quickstart-feature-flag-aspnet-core.md) to create a web app with a feature flag.
4652

47-
1. In the Azure portal, go to your configuration store and click **Feature manager**.
48-
49-
1. Click on the context menu for the *Beta* feature flag that you created in the quickstart. Click **Edit**.
53+
1. In the Azure portal, go to your configuration store and select **Feature manager**.
5054

51-
> [!div class="mx-imgBorder"]
52-
> ![Edit Beta feature flag](./media/edit-beta-feature-flag.png)
55+
:::image type="content" source="./media/feature-filters/edit-beta-feature-flag.png" alt-text="Screenshot of the Azure portal, selecting the Edit option for the Beta feature flag, under Feature manager.":::
5356

54-
1. In the **Edit** screen, check the **Enable feature flag** checkbox if it isn't already enabled. Then check the **Use feature filter** checkbox and select **Custom**.
57+
1. On the line with the Beta feature flag you created in the quickstart, select the context menu and then **Edit**.
5558

56-
1. In the **Name** field, select *Microsoft.Percentage*.
59+
1. In the **Edit feature flag** pane that opens, check the **Enable feature flag** checkbox if it isn't already enabled. Then check the **Use feature filter** checkbox and select **Create**.
5760

58-
> [!div class="mx-imgBorder"]
59-
> ![Add feature filter](./media/feature-flag-add-filter.png)
61+
:::image type="content" source="./media/feature-filters/edit-a-feature-flag.png" alt-text="Screenshot of the Azure portal, filling out the form 'Edit feature flag'.":::
6062

61-
1. Click the context menu next to the feature filter name. Click **Edit filter parameters**.
63+
1. The pane **Create a new filter** opens. Under **Filter type**, select **Targeting filter** to enable a new filter for specific users or a group.
6264

63-
> [!div class="mx-imgBorder"]
64-
> ![Edit feature filter parameters](./media/feature-flags-edit-filter-parameters.png)
65+
:::image type="content" source="./media/feature-filters/add-targeting-filter.png" alt-text="Screenshot of the Azure portal, creating a new targeting filter.":::
6566

66-
1. Enter a **Name** of *Value* and a **Value** of 50. The **Value** field indicates the percentage of requests for which to enable the feature filter.
67+
1. Optionally expand the **Evaluation flow** menu to see a graph showing how the targeting filter is evaluated in the selected scenario. Leave the **Default Percentage** at 50. The options **Override by Groups** and **Override by Users** let you enable or disable the feature flag for select groups or users. These options are disabled by default.
68+
1. Select **Add** to save the new feature filter and return to the **Edit feature flag** screen.
6769

68-
> [!div class="mx-imgBorder"]
69-
> ![Set feature filter parameters](./media/feature-flag-set-filter-parameters.png)
70+
1. The feature filter you created is now listed in the feature flag details. Select **Apply** to save the new feature flag settings.
7071

71-
1. Click **Apply** to return to the **Edit feature flag** screen. Then click **Apply** again to save the feature flag settings.
72+
:::image type="content" source="./media/feature-filters/feature-flag-edit-apply-filter.png" alt-text="Screenshot of the Azure portal, applying new targeting filter.":::
7273

73-
1. On the **Feature manager** page, the feature flag now has a **Feature filter** value of *Custom*.
74+
1. On the **Feature manager** page, the feature flag now has a **Feature filter(s)** value of **1**.
7475

75-
> [!div class="mx-imgBorder"]
76-
> ![Feature flag listed with a Feature filter value of "Custom"](./media/feature-flag-filter-custom.png)
76+
:::image type="content" source="./media/feature-filters/updated-feature-flag.png" alt-text="Screenshot of the Azure portal, displaying updated feature flag.":::
7777

7878
## Feature filters in action
7979

8080
To see the effects of this feature flag, launch the application and hit the **Refresh** button in your browser multiple times. You'll see that the *Beta* item appears on the toolbar about 50% of the time. It's hidden the rest of the time, because the `PercentageFilter` deactivates the *Beta* feature for a subset of requests. The following video shows this behavior in action.
8181

82-
> [!div class="mx-imgBorder"]
83-
> ![TargetingFilter in action](./media/feature-flags-percentagefilter.gif)
82+
:::image type="content" source="./media/feature-filters/feature-flags-percentagefilter.gif" alt-text="Screenshot of a web browser showing a targeting filter in action.":::
8483

8584
## Next steps
8685

31.7 KB
Loading
38.6 KB
Loading
63.8 KB
Loading
31 KB
Loading
51.6 KB
Loading
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)