Skip to content

Commit c2f81d2

Browse files
authored
Merge pull request #99382 from jimmyca15/user/jimmyca/featureManagementRelease
Updated Azure App Configuration feature management documentation.
2 parents 9329170 + 598a668 commit c2f81d2

File tree

3 files changed

+26
-32
lines changed

3 files changed

+26
-32
lines changed

articles/azure-app-configuration/quickstart-feature-flag-aspnet-core.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ Add the [Secret Manager tool](https://docs.microsoft.com/aspnet/core/security/ap
8282
1. Add reference to the `Microsoft.Azure.AppConfiguration.AspNetCore` and the `Microsoft.FeatureManagement.AspNetCore` NuGet packages by running the following commands:
8383

8484
```
85-
dotnet add package Microsoft.Azure.AppConfiguration.AspNetCore --version 2.0.0-preview-009470001-12
86-
dotnet add package Microsoft.FeatureManagement.AspNetCore --version 1.0.0-preview-009000001-1251
85+
dotnet add package Microsoft.Azure.AppConfiguration.AspNetCore --version 3.0.0-preview-010560002-1165
86+
dotnet add package Microsoft.FeatureManagement.AspNetCore --version 2.0.0-preview-010610001-1263
8787
```
8888

8989
1. Run the following command to restore packages for your project:
@@ -106,12 +106,6 @@ Add the [Secret Manager tool](https://docs.microsoft.com/aspnet/core/security/ap
106106

107107
You can access this secret with the App Configuration API. A colon (:) works in the configuration name with the App Configuration API on all supported platforms. See [Configuration by environment](https://docs.microsoft.com/aspnet/core/fundamentals/configuration).
108108

109-
1. Open *Program.cs*, and add a reference to the .NET Core App Configuration provider:
110-
111-
```csharp
112-
using Microsoft.Extensions.Configuration.AzureAppConfiguration;
113-
```
114-
115109
1. Update the `CreateWebHostBuilder` method to use App Configuration by calling the `config.AddAzureAppConfiguration()` method.
116110

117111
> [!IMPORTANT]

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

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,32 @@ The .NET Feature Management libraries extend the framework with comprehensive fe
6464
1. Update the `Main` method to connect to App Configuration, specifying the `UseFeatureFlags` option so that feature flags are retrieved. Then display a message if the `Beta` feature flag is enabled.
6565
6666
```csharp
67-
static void Main(string[] args)
67+
public static void Main(string[] args)
68+
{
69+
AsyncMain().Wait();
70+
}
71+
72+
private static async Task AsyncMain()
6873
{
6974
IConfigurationRoot configuration = new ConfigurationBuilder()
70-
.AddAzureAppConfiguration(options =>
71-
{
75+
.AddAzureAppConfiguration(options =>
76+
{
7277
options.Connect(Environment.GetEnvironmentVariable("ConnectionString"))
73-
.UseFeatureFlags();
78+
.UseFeatureFlags();
7479
}).Build();
75-
76-
IServiceCollection services = new ServiceCollection();
77-
services.AddSingleton<IConfiguration>(configuration).AddFeatureManagement();
78-
IFeatureManager featureManager = services.BuildServiceProvider().GetRequiredService<IFeatureManager>();
79-
80-
if (featureManager.IsEnabled("Beta"))
81-
{
82-
Console.WriteLine("Welcome to the beta");
80+
81+
IServiceCollection services = new ServiceCollection();
82+
83+
services.AddSingleton<IConfiguration>(configuration).AddFeatureManagement();
84+
85+
using (ServiceProvider serviceProvider = services.BuildServiceProvider())
86+
{
87+
IFeatureManager featureManager = serviceProvider.GetRequiredService<IFeatureManager>();
88+
89+
if (await featureManager.IsEnabledAsync("Beta"))
90+
{
91+
Console.WriteLine("Welcome to the beta!");
92+
}
8393
}
8494
8595
Console.WriteLine("Hello World!");

articles/azure-app-configuration/use-feature-flags-dotnet-core.md

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ The basic pattern of feature management is to first check if a feature flag is s
175175
```csharp
176176
IFeatureManager featureManager;
177177
...
178-
if (featureManager.IsEnabled(nameof(MyFeatureFlags.FeatureA)))
178+
if (await featureManager.IsEnabledAsync(nameof(MyFeatureFlags.FeatureA)))
179179
{
180180
// Run the following code
181181
}
@@ -252,7 +252,7 @@ The feature `<feature>` tag can also be used to show content if any or all featu
252252

253253
## MVC filters
254254

255-
You can set up MVC filters so that they're activated based on the state of a feature flag. The following code adds an MVC filter named `SomeMvcFilter`. This filter is triggered within the MVC pipeline only if `FeatureA` is enabled.
255+
You can set up MVC filters so that they're activated based on the state of a feature flag. The following code adds an MVC filter named `SomeMvcFilter`. This filter is triggered within the MVC pipeline only if `FeatureA` is enabled. This capability is limited to `IAsyncActionFilter`.
256256

257257
```csharp
258258
using Microsoft.FeatureManagement.FeatureFilters;
@@ -267,16 +267,6 @@ public void ConfigureServices(IServiceCollection services)
267267
}
268268
```
269269

270-
## Routes
271-
272-
You can use feature flags to dynamically expose routes. The following code adds a route, which sets `Beta` as the default controller only when `FeatureA` is enabled:
273-
274-
```csharp
275-
app.UseMvc(routes => {
276-
routes.MapRouteForFeature(nameof(MyFeatureFlags.FeatureA), "betaDefault", "{controller=Beta}/{action=Index}/{id?}");
277-
});
278-
```
279-
280270
## Middleware
281271

282272
You can also use feature flags to conditionally add application branches and middleware. The following code inserts a middleware component in the request pipeline only when `FeatureA` is enabled:

0 commit comments

Comments
 (0)