Skip to content

Commit f13804b

Browse files
committed
Fix the code for endpoint retrieval
1 parent a31bcd4 commit f13804b

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,6 @@ Connect to your App Configuration store using Microsoft Entra ID (recommended),
6464
```
6565
---
6666
67-
1. Run the following command to restore packages for your project:
68-
69-
```dotnetcli
70-
dotnet restore
71-
```
72-
7367
1. Create a user secret for the application by navigating into the *TestAppConfig* folder and running the following command.
7468
7569
### [Microsoft Entra ID (recommended)](#tab/entra-id)
@@ -124,7 +118,7 @@ Connect to your App Configuration store using Microsoft Entra ID (recommended),
124118
var builder = WebApplication.CreateBuilder(args);
125119
126120
// Retrieve the endpoint
127-
string endpoint = builder.Configuration.Get("Endpoints:AppConfiguration");
121+
string endpoint = builder.Configuration.GetValue<string>("Endpoints:AppConfiguration");
128122
129123
// Load configuration from Azure App Configuration
130124
builder.Configuration.AddAzureAppConfiguration(options =>

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

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
title: 'Tutorial: Use variant feature flags from Azure App Configuration in an ASP.NET application'
2+
title: 'Tutorial: Use variant feature flags from Azure App Configuration in an ASP.NET Core application'
33
titleSuffix: Azure App configuration
4-
description: In this tutorial, you learn how to use variant feature flags in an ASP.NET application
4+
description: In this tutorial, you learn how to use variant feature flags in an ASP.NET Core application
55
#customerintent: As a user of Azure App Configuration, I want to learn how I can use variants and variant feature flags in my ASP.NET application.
66
author: rossgrambo
77
ms.author: rossgrambo
@@ -11,7 +11,7 @@ ms.topic: tutorial
1111
ms.date: 10/18/2024
1212
---
1313

14-
# Tutorial: Use variant feature flags from Azure App Configuration in an ASP.NET application
14+
# Tutorial: Use variant feature flags from Azure App Configuration in an ASP.NET Core application
1515

1616
In this tutorial, you use a variant feature flag to manage experiences for different user segments in an example application, *Quote of the Day*. You utilize the variant feature flag created in [Use variant feature flags](./use-variant-feature-flags.md). Before proceeding, ensure you create the variant feature flag named *Greeting* in your App Configuration store.
1717

@@ -28,10 +28,11 @@ In this tutorial, you use a variant feature flag to manage experiences for diffe
2828
dotnet new razor --auth Individual -o QuoteOfTheDay
2929
```
3030
31-
1. Create a [user secret](/aspnet/core/security/app-secrets) for the application by navigating into the *QuoteOfTheDay* folder and run the following command. This secret holds the endpoint for your App Configuration.
31+
1. Create a [user secret](/aspnet/core/security/app-secrets) for the application by navigating into the *QuoteOfTheDay* folder and run the following commands. This secret holds the endpoint for your App Configuration store.
3232
3333
```dotnetcli
34-
dotnet user-secrets set Endpoints:AppConfiguration "<App Configuration Endpoint>"
34+
dotnet user-secrets init
35+
dotnet user-secrets set Endpoints:AppConfiguration "<Your App Configuration store endpoint>"
3536
```
3637
3738
1. Add the latest versions of the required packages.
@@ -44,26 +45,30 @@ In this tutorial, you use a variant feature flag to manage experiences for diffe
4445
4546
## Connect to App Configuration for feature management
4647
47-
1. In *Program.cs*, add the following using statements.
48+
1. Open *Program.cs*, and add the following using statements.
4849
4950
```csharp
5051
using Azure.Identity;
5152
using Microsoft.Extensions.Configuration.AzureAppConfiguration;
5253
using Microsoft.FeatureManagement;
5354
```
5455
55-
1. In *Program.cs*, under the line `var builder = WebApplication.CreateBuilder(args);`, add the App Configuration provider, which pulls down the configuration from Azure App Configuration when the application starts. By default, the `UseFeatureFlags` method pulls down all feature flags with no label.
56+
1. Add the following code to connect to your App Configuration store and call `UseFeatureFlags` to pull down all feature flags with no label.
5657
5758
You use the `DefaultAzureCredential` to authenticate to your App Configuration store. Follow the [instructions](./concept-enable-rbac.md#authentication-with-token-credentials) to assign your credential the **App Configuration Data Reader** role. Be sure to allow sufficient time for the permission to propagate before running your application.
5859
5960
```csharp
61+
var builder = WebApplication.CreateBuilder(args);
62+
63+
// Retrieve the endpoint
64+
string endpoint = builder.Configuration.GetValue<string>("Endpoints:AppConfiguration");
65+
66+
// Load configuration and feature flags from Azure App Configuration
6067
builder.Configuration
6168
.AddAzureAppConfiguration(options =>
6269
{
63-
string endpoint = builder.Configuration.Get("Endpoints:AppConfiguration");
64-
options.Connect(new Uri(endpoint), new DefaultAzureCredential());
65-
66-
options.UseFeatureFlags();
70+
options.Connect(new Uri(endpoint), new DefaultAzureCredential())
71+
.UseFeatureFlags();
6772
});
6873
```
6974

0 commit comments

Comments
 (0)