Skip to content

Commit bee133d

Browse files
committed
Addressing Lisa's feedback.
1 parent fbec42c commit bee133d

File tree

1 file changed

+62
-5
lines changed

1 file changed

+62
-5
lines changed

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

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@ Use the [.NET Core command-line interface (CLI)](https://docs.microsoft.com/dotn
4949

5050
Add the [Secret Manager tool](https://docs.microsoft.com/aspnet/core/security/app-secrets) to your project. The Secret Manager tool stores sensitive data for development work outside your project tree. This approach helps prevent the accidental sharing of app secrets within source code.
5151

52+
> [!IMPORTANT]
53+
> Significant differences exist between .NET Core 2.x and 3.x. Select the correct syntax based on your environment.
54+
5255
1. Open the *.csproj* file.
5356
1. Add a `UserSecretsId` element as shown in the following example, and replace its value with your own, which typically is a GUID:
5457

58+
#### [.NET Core 2.x](#tab/core2x)
5559
```xml
5660
<Project Sdk="Microsoft.NET.Sdk.Web">
5761

@@ -67,14 +71,25 @@ Add the [Secret Manager tool](https://docs.microsoft.com/aspnet/core/security/ap
6771

6872
</Project>
6973
```
74+
#### [.NET Core 3.x](#tab/core3x)
75+
```xml
76+
<Project Sdk="Microsoft.NET.Sdk.Web">
77+
78+
<PropertyGroup>
79+
<TargetFramework>netcoreapp3.1</TargetFramework>
80+
<UserSecretsId>79a3edd0-2092-40a2-a04d-dcb46d5ca9ed</UserSecretsId>
81+
</PropertyGroup>
82+
</Project>
83+
```
84+
---
7085

7186
## Connect to an App Configuration store
7287

7388
1. Add reference to the `Microsoft.Azure.AppConfiguration.AspNetCore` and the `Microsoft.FeatureManagement.AspNetCore` NuGet packages by running the following commands:
7489

7590
```
76-
dotnet add package Microsoft.Azure.AppConfiguration.AspNetCore --version 2.0.0-preview-009470001-12
77-
dotnet add package Microsoft.FeatureManagement.AspNetCore --version 1.0.0-preview-009000001-1251
91+
dotnet add package Microsoft.Azure.AppConfiguration.AspNetCore --version 3.0.0-preview-011100002-1192
92+
dotnet add package Microsoft.FeatureManagement.AspNetCore --version 2.0.0-preview-010610001-1263
7893
```
7994

8095
1. Run the following command to restore packages for your project:
@@ -150,28 +165,70 @@ Add the [Secret Manager tool](https://docs.microsoft.com/aspnet/core/security/ap
150165

151166
1. Update the `ConfigureServices` method to add feature flag support by calling the `services.AddFeatureManagement()` method. Optionally, you can include any filter to be used with feature flags by calling `services.AddFeatureFilter<FilterType>()`:
152167

168+
#### [.NET Core 2.x](#tab/core2x)
153169
```csharp
154170
public void ConfigureServices(IServiceCollection services)
155171
{
172+
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
156173
services.AddFeatureManagement();
157174
}
158175
```
176+
#### [.NET Core 3.x](#tab/core3x)
177+
```csharp
178+
public void ConfigureServices(IServiceCollection services)
179+
{
180+
services.AddControllersWithViews(); services.AddFeatureManagement();
181+
}
182+
---
159183

160184
1. Update the `Configure` method to add a middleware to allow the feature flag values to be refreshed at a recurring interval while the ASP.NET Core web app continues to receive requests.
161185

162186
#### [.NET Core 2.x](#tab/core2x)
163187
```csharp
164188
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
165189
{
166-
app.UseAzureAppConfiguration();
167-
app.UseMvc();
190+
if (env.IsDevelopment())
191+
{
192+
app.UseDeveloperExceptionPage();
193+
}
194+
else
195+
{
196+
app.UseExceptionHandler("/Home/Error");
197+
}
198+
199+
app.UseStaticFiles();
200+
app.UseCookiePolicy();
201+
app.UseAzureAppConfiguration();
202+
app.UseMvc(routes =>
203+
{
204+
routes.MapRoute(
205+
name: "default",
206+
template: "{controller=Home}/{action=Index}/{id?}");
207+
});
168208
}
169209
```
170210
#### [.NET Core 3.x](#tab/core3x)
171211
```csharp
172212
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
173213
{
174-
app.UseAzureAppConfiguration();
214+
if (env.IsDevelopment())
215+
{
216+
app.UseDeveloperExceptionPage();
217+
}
218+
else
219+
{
220+
app.UseExceptionHandler("/Home/Error");
221+
}
222+
app.UseStaticFiles();
223+
app.UseRouting();
224+
app.UseAuthorization();
225+
app.UseEndpoints(endpoints =>
226+
{
227+
endpoints.MapControllerRoute(
228+
name: "default",
229+
pattern: "{controller=Home}/{action=Index}/{id?}");
230+
});
231+
app.UseAzureAppConfiguration();
175232
}
176233
```
177234
---

0 commit comments

Comments
 (0)