Skip to content

Commit 2178f6a

Browse files
committed
PR review
1 parent 28b186a commit 2178f6a

File tree

1 file changed

+18
-36
lines changed

1 file changed

+18
-36
lines changed

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

Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ms.date: 12/02/2024
1212

1313
# Roll out features to targeted audiences in an ASP.NET Core application
1414

15-
In this guide, you'll use the targeting filter to roll out a feature to a targeted audience for your ASP.NET Core application. For more information about the targeting filter, see [Roll out features to targeted audiences](./howto-targetingfilter.md).
15+
In this guide, you'll use the targeting filter to roll out a feature to targeted audiences for your ASP.NET Core application. For more information about the targeting filter, see [Roll out features to targeted audiences](./howto-targetingfilter.md).
1616

1717
## Prerequisites
1818

@@ -31,18 +31,10 @@ In this section, you create a web application that allows users to sign in and u
3131
dotnet new webapp --auth Individual -o TestFeatureFlags
3232
```
3333

34-
1. Navigate to the newly created *TestFeatureFlags* directory.
35-
36-
```dotnetcli
37-
cd TestFeatureFlags
38-
```
39-
40-
1. Add references to the following NuGet packages to connect to your App Configuration store using Microsoft Entra ID (recommended) or a connection string.
34+
1. Navigate to the newly created *TestFeatureFlags* directory and add references to the following NuGet packages.
4135

4236
### [Microsoft Entra ID (recommended)](#tab/entra-id)
4337

44-
Add references to the following NuGet packages.
45-
4638
```dotnetcli
4739
dotnet add package Microsoft.Azure.AppConfiguration.AspNetCore
4840
dotnet add package Microsoft.FeatureManagement.AspNetCore
@@ -51,21 +43,13 @@ In this section, you create a web application that allows users to sign in and u
5143
5244
### [Connection string](#tab/connection-string)
5345
54-
Add references to the following NuGet packages.
55-
5646
```dotnetcli
5747
dotnet add package Microsoft.Azure.AppConfiguration.AspNetCore
5848
dotnet add package Microsoft.FeatureManagement.AspNetCore
5949
```
6050
---
6151
62-
1. Restore packages for your project:
63-
64-
```dotnetcli
65-
dotnet restore
66-
```
67-
68-
1. Create a user secret for the application by navigating into the *TestFeatureFlags* folder and running the following command.
52+
1. Create a user secret for the application by running the following commands.
6953
7054
### [Microsoft Entra ID (recommended)](#tab/entra-id)
7155
@@ -78,11 +62,11 @@ In this section, you create a web application that allows users to sign in and u
7862
7963
### [Connection string](#tab/connection-string)
8064
81-
The command uses [Secret Manager](/aspnet/core/security/app-secrets) to store a secret named `ConnectionStrings:AppConfig`, which stores the connection string for your App Configuration store. Replace the `<your_connection_string>` placeholder with your App Configuration store's connection string. You can find the connection string in your App Configuration store's **Access settings** in the Azure portal.
65+
The command uses [Secret Manager](/aspnet/core/security/app-secrets) to store a secret named `ConnectionStrings:AppConfiguration`, which stores the connection string for your App Configuration store. Replace the `<your-App-Configuration-connection-string>` placeholder with your App Configuration store's read-only connection string. You can find the connection string in your App Configuration store's **Access settings** in the Azure portal.
8266
8367
```dotnetcli
8468
dotnet user-secrets init
85-
dotnet user-secrets set ConnectionStrings:AppConfig "<your_connection_string>"
69+
dotnet user-secrets set ConnectionStrings:AppConfiguration "<your-App-Configuration-connection-string>"
8670
```
8771
---
8872
@@ -102,18 +86,15 @@ In this section, you create a web application that allows users to sign in and u
10286
10387
var builder = WebApplication.CreateBuilder(args);
10488
105-
// Load configuration from Azure App Configuration
106-
builder.Configuration.AddAzureAppConfiguration(options =>
107-
{
108-
string endpoint = builder.Configuration.Get("Endpoints:AppConfiguration");
109-
options.Connect(new Uri(endpoint), new DefaultAzureCredential());
110-
});
111-
112-
// Load feature flag configuration from Azure App Configuration
89+
// Retrieve the endpoint
90+
string endpoint = builder.Configuration.GetValue<string>("Endpoints:AppConfiguration")
91+
?? throw new InvalidOperationException("The setting `Endpoints:AppConfiguration` was not found.");
92+
93+
// Connect to Azure App Configuration and load all feature flags with no label
11394
builder.Configuration.AddAzureAppConfiguration(options =>
11495
{
115-
options.Connect(new Uri(endpoint), new DefaultAzureCredential());
116-
options.UseFeatureFlags();
96+
options.Connect(new Uri(endpoint), new DefaultAzureCredential())
97+
.UseFeatureFlags();
11798
});
11899
119100
// Add Azure App Configuration middleware to the container of services
@@ -136,14 +117,15 @@ In this section, you create a web application that allows users to sign in and u
136117
137118
var builder = WebApplication.CreateBuilder(args);
138119
139-
// Retrieve the App Config connection string
140-
string AppConfigConnectionString = builder.Configuration.GetConnectionString("AppConfig") ?? throw new InvalidOperationException("Connection string 'AppConfig' not found."); ;
120+
// Retrieve the connection string
121+
string connectionString = builder.Configuration.GetConnectionString("AppConfiguration")
122+
?? throw new InvalidOperationException("The connection string 'AppConfiguration' was not found.");
141123
142-
// Load feature flag configuration from Azure App Configuration
124+
// Connect to Azure App Configuration and load all feature flags with no label
143125
builder.Configuration.AddAzureAppConfiguration(options =>
144126
{
145-
options.Connect(AppConfigConnectionString);
146-
options.UseFeatureFlags();
127+
options.Connect(connectionString)
128+
.UseFeatureFlags();
147129
});
148130
149131
// Add Azure App Configuration middleware to the container of services

0 commit comments

Comments
 (0)