Skip to content

Commit 12a28cd

Browse files
committed
Update code snippet
1 parent f3aa976 commit 12a28cd

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

articles/azure-app-configuration/howto-create-snapshots.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ Edit the call to the `AddAzureAppConfiguration` method, which is often found in
9696
```csharp
9797
configurationBuilder.AddAzureAppConfiguration(options =>
9898
{
99+
string endpoint = Environment.GetEnvironmentVariable("Endpoint");
99100
options.Connect(new Uri(endpoint), new DefaultAzureCredential());
100101
// Select an existing snapshot by name. This will add all of the key-values from the snapshot to this application's configuration.
101102
options.SelectSnapshot("SnapshotName");

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,15 @@ var builder = WebApplication.CreateBuilder(args);
4747

4848
builder.Configuration.AddAzureAppConfiguration(options =>
4949
{
50-
options.Connect(builder.Configuration.GetValue<string>("Endpoints:AppConfiguration"))
51-
// Load configuration values with no label
52-
.Select(KeyFilter.Any, LabelFilter.Null)
53-
// Override with any configuration values specific to current hosting env
54-
.Select(KeyFilter.Any, builder.Environment.EnvironmentName);
50+
string endpoint = Environment.GetEnvironmentVariable("Endpoint");
51+
options.Connect(new Uri(endpoint), new DefaultAzureCredential())
52+
// Load configuration values with no label
53+
.Select(KeyFilter.Any, LabelFilter.Null)
54+
// Override with any configuration values specific to current hosting env
55+
.Select(KeyFilter.Any, builder.Environment.EnvironmentName);
5556
});
5657
```
5758

58-
> [!IMPORTANT]
59-
> The preceding code snippet uses the Secret Manager tool to load App Configuration endpoint. For information storing the endpoint using the Secret Manager, see [Quickstart for Azure App Configuration with ASP.NET Core](quickstart-aspnet-core-app.md).
60-
6159
The `Select` method is called twice. The first time, it loads configuration values with no label. Then, it loads configuration values with the label corresponding to the current environment. These environment-specific values override any corresponding values with no label. You don't need to define environment-specific values for every key. If a key doesn't have a value with a label corresponding to the current environment, it uses the value with no label.
6260

6361
## Test in different environments

0 commit comments

Comments
 (0)