You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-app-configuration/howto-feature-filters-aspnet-core.md
+19-21Lines changed: 19 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,10 +18,10 @@ Feature flags allow you to activate or deactivate functionality in your applicat
18
18
19
19
In contrast, a _conditional feature flag_ allows the feature flag to be enabled or disabled dynamically. The application may behave differently, depending on the feature flag criteria. Suppose you want to show your new feature to a small subset of users at first. A conditional feature flag allows you to enable the feature flag for some users while disabling it for others. _Feature filters_ determine the state of the feature flag each time it's evaluated.
20
20
21
-
The `Microsoft.FeatureManagement` library includes built-in feature filters:
21
+
The `Microsoft.FeatureManagement` library includes built-in feature filters accessible from the Azure App Configuration portal.
22
22
23
-
-`TimeWindowFilter` enables the feature flag during a specified window of time.
24
-
-`TargetingFilter` enables the feature flag for specified users and groups.
23
+
-Time window filter enables the feature flag during a specified window of time.
24
+
-Targeting filter enables the feature flag for specified users and groups.
25
25
26
26
You can also create your own feature filter that implements the `Microsoft.FeatureManagement.IFeatureFilter` interface. For more information, see [Implementing a Feature Filter](https://github.com/microsoft/FeatureManagement-Dotnet#implementing-a-feature-filter).
27
27
@@ -30,41 +30,37 @@ You can also create your own feature filter that implements the `Microsoft.Featu
30
30
- 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.
31
31
- Install the [`Microsoft.FeatureManagement.AspNetCore`](https://www.nuget.org/packages/Microsoft.FeatureManagement.AspNetCore/) package of version **3.0.0** or later.
32
32
33
-
## Set up feature management
33
+
## Register a feature filter
34
34
35
-
Since `Microsoft.FeatureManagement` 3.0.0, built-in filters, except for the `TargetingFilter`, are added automatically when feature management is registered. For more information on using `TargetingFilter`, see [Enable staged rollout of features for targeted audiences](./howto-targetingfilter-aspnet-core.md).
35
+
If you have a [custom feature filter](https://github.com/microsoft/FeatureManagement-Dotnet#implementing-a-feature-filter), you can register it by calling the `AddFeatureFilter` method.
36
36
37
37
```csharp
38
-
services.AddFeatureManagement();
38
+
services.AddFeatureManagement()
39
+
.AddFeatureFilter<MyCriteriaFilter>();
39
40
```
40
41
41
-
> [!TIP]
42
-
> You can create your own feature filter that implements the `Microsoft.FeatureManagement.IFeatureFilter` interface. The feature filter can be registered by calling the `AddFeatureFilter` method. For built-in feature filters, calling `AddFeatureFilter` is no longer needed since `Microsoft.FeatureManagement` 3.0.0.
43
-
>
44
-
> ```csharp
45
-
>services.AddFeatureManagement()
46
-
> .AddFeatureFilter<MyCriteriaFilter>();
47
-
> ```
42
+
Starting with version *3.0.0* of `Microsoft.FeatureManagement`, the following built-in filters are registered automatically as part of the `AddFeatureManagement` call, so you don't need to register them.
48
43
49
-
## Configure a feature filter in Azure App Configuration
44
+
> [!TIP]
45
+
> For more information on using `TargetingFilter`, see [Enable staged rollout of features for targeted audiences](./howto-targetingfilter-aspnet-core.md).
Youcanconfigurethesesettingsfor feature flags defined in Azure App Configuration. For example, follow these steps to use `TimeWindowFilter` to activate the feature flag at a certain moment:
49
+
In this section, you will learn how to add a feature filter to the **Beta** feature flag you created in the [Quickstart](./quickstart-feature-flag-aspnet-core.md). The following steps use the built-in `TimeWindowFilter` as an example.
54
50
55
51
1. In the Azure portal, go to your configuration store and select **Feature manager**.
56
52
57
-
:::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.":::
53
+
:::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.":::
58
54
59
-
1. On the line with the Beta feature flag you created in the quickstart, select the context menu and then **Edit**.
55
+
1. On the line with the **Beta** feature flag you created in the quickstart, select the context menu and then **Edit**.
60
56
61
57
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**.
62
58
63
59
:::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'.":::
64
60
65
-
1. The pane **Create a new filter** opens. Under **Filter type**, select **Time window filter** to enable a new filter for a specific time window.
61
+
1. The pane **Create a new filter** opens. Under **Filter type**, select **Time window filter**.
66
62
67
-
1. Set the **Expiry date** to **Never** and set the **Start date** to 10 minutes ahead of the current time. For example, if the current time is 1:50 PM on February 28, 2024, please set the time to 10 minutes later, which would be 2:00 PM.
63
+
1. Set the **Start date** to **Custom** and select a time a few minutes ahead of your current time. Set the **Expiry date**to **Never**
68
64
69
65
:::image type="content" source="./media/feature-filters/add-time-window-filter.png" alt-text="Screenshot of the Azure portal, creating a new time window filter.":::
70
66
@@ -80,7 +76,9 @@ You can configure these settings for feature flags defined in Azure App Configur
80
76
81
77
## Feature filters in action
82
78
83
-
Toseetheeffectsofthisfeatureflag, launchtheapplication. You'll see that the *Beta* item will not appears on the toolbar. It'shidden, becausethe `TimeWindowFilter` deactivatesthe*Beta*feature. Afterabout10minutes, clicktherefreshbuttoninyoubrowserandyou'll see the *Beta* item will appear again because the `TimeWindowFilter` will activate the *Beta* feature when time hits the time window.
79
+
Relaunch the application you created in the [Quickstart](./quickstart-feature-flag-aspnet-core.md). If your current time is earlier than the start time set for the time window filter, the **Beta** menu item will not appear on the toolbar. This is because the **Beta** feature flag is disabled by the time window filter.
80
+
81
+
Once the start time has passed, refresh your browser a few times. You will notice that the **Beta** menu item will now appear. This is because the **Beta** feature flag is now enabled by the time window filter.
0 commit comments