Skip to content

Commit 0984839

Browse files
authored
Merge pull request #287724 from rossgrambo/main
Azure App Configuration - Prepare for Feature Management 4.0.0 release.
2 parents 54e4a1e + a533ca2 commit 0984839

7 files changed

+85
-337
lines changed

articles/azure-app-configuration/feature-management-dotnet-reference.md

Lines changed: 60 additions & 257 deletions
Large diffs are not rendered by default.

articles/azure-app-configuration/howto-geo-replication.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ configurationBuilder.AddAzureAppConfiguration(options =>
275275
```
276276

277277
> [!NOTE]
278-
> Load balancing support is available if you use version **8.0.0-preview.3** or later of any of the following packages.
278+
> Load balancing support is available if you use version **8.0.0** or later of any of the following packages.
279279
> - `Microsoft.Extensions.Configuration.AzureAppConfiguration`
280280
> - `Microsoft.Azure.AppConfiguration.AspNetCore`
281281
> - `Microsoft.Azure.AppConfiguration.Functions.Worker`

articles/azure-app-configuration/howto-targetingfilter-aspnet-core.md

Lines changed: 14 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -199,68 +199,26 @@ In this section, you create a web application that allows users to sign in and u
199199
200200
## Enable targeting for the web application
201201
202-
The targeting filter evaluates a user's feature state based on the user's targeting context, which comprises the user ID and the groups the user belongs to. In this example, you use the signed-in user's email address as the user ID and the domain name of the email address as the group.
202+
A targeting context is required for feature evaluation with targeting. You can provide it as a parameter to the `featureManager.IsEnabledAsync` API explicitly. In ASP.NET Core, the targeting context can also be provided through the service collection as an ambient context by implementing the [ITargetingContextAccessor](./feature-management-dotnet-reference.md#itargetingcontextaccessor) interface.
203203
204-
1. Add an *ExampleTargetingContextAccessor.cs* file with the following code. You implement the `ITargetingContextAccessor` interface to provide the targeting context for the signed-in user of the current request.
204+
### Targeting Context Accessor
205205
206-
```csharp
207-
using Microsoft.FeatureManagement.FeatureFilters;
206+
To provide the targeting context, pass your implementation type of the `ITargetingContextAccessor` to the `WithTargeting<T>` method. If no type is provided, a default implementation is used, as shown in the following code snippet. The default targeting context accessor utilizes `HttpContext.User.Identity.Name` as `UserId` and `HttpContext.User.Claims` of type [`Role`](/dotnet/api/system.security.claims.claimtypes.role#system-security-claims-claimtypes-role) for `Groups`. You can reference the [DefaultHttpTargetingContextAccessor](https://github.com/microsoft/FeatureManagement-Dotnet/blob/main/src/Microsoft.FeatureManagement.AspNetCore/DefaultHttpTargetingContextAccessor.cs) to implement your own if customization is needed. To learn more about implementing the `ITargetingContextAccessor`, see the [feature reference for targeting](./feature-management-dotnet-reference.md#itargetingcontextaccessor).
208207
209-
namespace TestFeatureFlags
210-
{
211-
public class ExampleTargetingContextAccessor : ITargetingContextAccessor
212-
{
213-
private const string TargetingContextLookup = "ExampleTargetingContextAccessor.TargetingContext";
214-
private readonly IHttpContextAccessor _httpContextAccessor;
215-
216-
public ExampleTargetingContextAccessor(IHttpContextAccessor httpContextAccessor)
217-
{
218-
_httpContextAccessor = httpContextAccessor ?? throw new ArgumentNullException(nameof(httpContextAccessor));
219-
}
220-
221-
public ValueTask<TargetingContext> GetContextAsync()
222-
{
223-
HttpContext httpContext = _httpContextAccessor.HttpContext;
224-
if (httpContext.Items.TryGetValue(TargetingContextLookup, out object value))
225-
{
226-
return new ValueTask<TargetingContext>((TargetingContext)value);
227-
}
228-
List<string> groups = new List<string>();
229-
if (httpContext.User.Identity.Name != null)
230-
{
231-
groups.Add(httpContext.User.Identity.Name.Split("@", StringSplitOptions.None)[1]);
232-
}
233-
TargetingContext targetingContext = new TargetingContext
234-
{
235-
UserId = httpContext.User.Identity.Name,
236-
Groups = groups
237-
};
238-
httpContext.Items[TargetingContextLookup] = targetingContext;
239-
return new ValueTask<TargetingContext>(targetingContext);
240-
}
241-
}
242-
}
243-
```
208+
``` C#
209+
// Existing code in Program.cs
210+
// ... ...
244211
245-
1. Open the *Program.cs* file and enable the targeting filter by calling the `WithTargeting` method. You pass in the type `ExampleTargetingContextAccessor` that the targeting filter will use to get the targeting context during feature flag evaluation. Add `HttpContextAccessor` to the service collection to allow `ExampleTargetingContextAccessor` to access the signed-in user information from the `HttpContext`.
212+
// Add feature management to the container of services
213+
builder.Services.AddFeatureManagement()
214+
.WithTargeting();
246215
247-
```csharp
248-
// Existing code in Program.cs
249-
// ... ...
250-
251-
// Add feature management to the container of services
252-
builder.Services.AddFeatureManagement()
253-
.WithTargeting<ExampleTargetingContextAccessor>();
216+
// The rest of existing code in Program.cs
217+
// ... ...
218+
```
254219

255-
// Add HttpContextAccessor to the container of services.
256-
builder.Services.AddHttpContextAccessor();
257-
258-
// The rest of existing code in Program.cs
259-
// ... ...
260-
```
261-
262-
> [!NOTE]
263-
> For Blazor applications, see [instructions](./faq.yml#how-to-enable-feature-management-in-blazor-applications-or-as-scoped-services-in--net-applications) for enabling feature management as scoped services.
220+
> [!NOTE]
221+
> For Blazor applications, see [instructions](./faq.yml#how-to-enable-feature-management-in-blazor-applications-or-as-scoped-services-in--net-applications) for enabling feature management as scoped services.
264222
265223
## Targeting filter in action
266224

@@ -280,10 +238,6 @@ The targeting filter evaluates a user's feature state based on the user's target
280238
281239
Now sign in as `[email protected]`, using the password you set when registering the account. The **Beta** item doesn't appear on the toolbar, because `[email protected]` is specified as an excluded user.
282240

283-
You can create more users with `@contoso.com` and `@contoso-xyz.com` email addresses to see the behavior of the group settings.
284-
285-
Users with `contoso-xyz.com` email addresses won't see the **Beta** item. While 50% of users with `@contoso.com` email addresses will see the **Beta** item, the other 50% won't see the **Beta** item.
286-
287241
## Next steps
288242

289243
To learn more about the feature filters, continue to the following documents.

articles/azure-app-configuration/quickstart-feature-flag-azure-functions-csharp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ This project will use [dependency injection in .NET Azure Functions](../azure-fu
134134
Add a constructor used to obtain instances of `_featureManagerSnapshot` and `IConfigurationRefresherProvider` through dependency injection. From the `IConfigurationRefresherProvider`, you can obtain the instance of `IConfigurationRefresher`.
135135

136136
```csharp
137-
private readonly IFeatureManagerSnapshot _featureManagerSnapshot;
137+
private readonly IVariantFeatureManagerSnapshot _featureManagerSnapshot;
138138
private readonly IConfigurationRefresher _configurationRefresher;
139139

140-
public Function1(IFeatureManagerSnapshot featureManagerSnapshot, IConfigurationRefresherProvider refresherProvider)
140+
public Function1(IVariantFeatureManagerSnapshot featureManagerSnapshot, IConfigurationRefresherProvider refresherProvider)
141141
{
142142
_featureManagerSnapshot = featureManagerSnapshot;
143143
_configurationRefresher = refresherProvider.Refreshers.First();

articles/azure-app-configuration/quickstart-feature-flag-dotnet-background-service.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,16 @@ Add a feature flag called *Beta* to the App Configuration store and leave **Labe
117117
using Microsoft.FeatureManagement;
118118
```
119119
120-
1. Update the constructor of the `Worker` service to obtain instances of `IConfigurationRefresher` and `IFeatureManager` through dependency injection.
120+
1. Update the constructor of the `Worker` service to obtain instances of `IConfigurationRefresher` and `IVariantFeatureManager` through dependency injection.
121121
122122
```csharp
123123
public class Worker : BackgroundService
124124
{
125125
private readonly ILogger<Worker> _logger;
126126
private readonly IConfigurationRefresher _refresher;
127-
private readonly IFeatureManager _featureManager;
127+
private readonly IVariantFeatureManager _featureManager;
128128
129-
public Worker(ILogger<Worker> logger, IConfigurationRefresher refresher, IFeatureManager featureManager)
129+
public Worker(ILogger<Worker> logger, IConfigurationRefresher refresher, IVariantFeatureManager featureManager)
130130
{
131131
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
132132
_refresher = refresher ?? throw new ArgumentNullException(nameof(refresher));

articles/azure-app-configuration/quickstart-feature-flag-dotnet.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ You can use Visual Studio to create a new console app project.
4040

4141
1. Start Visual Studio, and select **File** > **New** > **Project**.
4242

43-
1. In **Create a new project**, filter on the **Console** project type and select **Console App**. If you want to create a .NET Framework app, please select **Console App (.NET Framework)** instead. Click **Next**.
43+
1. In **Create a new project**, filter on the **Console** project type and select **Console App**. If you want to create a .NET Framework app, select **Console App (.NET Framework)** instead. Click **Next**.
4444

45-
1. In **Configure your new project**, enter a project name. If you are creating a .NET Framework app, please select **.NET Framework 4.7.2** or higher under **Framework**. Click **Create**.
45+
1. In **Configure your new project**, enter a project name. If you're creating a .NET Framework app, select **.NET Framework 4.7.2** or higher under **Framework**. Click **Create**.
4646

4747
## Use the feature flag
4848

@@ -77,7 +77,7 @@ You can use Visual Studio to create a new console app project.
7777
7878
IFeatureDefinitionProvider featureDefinitionProvider = new ConfigurationFeatureDefinitionProvider(configuration);
7979
80-
IFeatureManager featureManager = new FeatureManager(
80+
IVariantFeatureManager featureManager = new FeatureManager(
8181
featureDefinitionProvider,
8282
new FeatureManagementOptions());
8383
@@ -103,7 +103,7 @@ You can use Visual Studio to create a new console app project.
103103
104104
IFeatureDefinitionProvider featureDefinitionProvider = new ConfigurationFeatureDefinitionProvider(configuration);
105105
106-
IFeatureManager featureManager = new FeatureManager(
106+
IVariantFeatureManager featureManager = new FeatureManager(
107107
featureDefinitionProvider,
108108
new FeatureManagementOptions());
109109
@@ -130,7 +130,7 @@ You can use Visual Studio to create a new console app project.
130130
setx ConnectionString "<connection-string-of-your-app-configuration-store>"
131131
```
132132
133-
Restart the command prompt to allow the change to take effect. Print the value of the environment variable to validate that it's set properly.
133+
Restart the command prompt to allow the change to take effect. Validate that it's set properly by printing the value of the environment variable.
134134
135135
### [PowerShell](#tab/powershell)
136136

articles/zone-pivot-groups.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,15 +1295,6 @@ groups:
12951295
title: .NET
12961296
- id: framework-spring
12971297
title: Spring Framework
1298-
# Owner: zhiyuanliang
1299-
- id: feature-management
1300-
title: Library version pivots
1301-
prompt: Choose a release
1302-
pivots:
1303-
- id: stable-version
1304-
title: Stable release
1305-
- id: preview-version
1306-
title: Preview release
13071298
# Owner: avanigupta
13081299
- id: appconfig-data-plane-api-version
13091300
title: API version pivots

0 commit comments

Comments
 (0)