Skip to content

Commit 013bb9c

Browse files
Merge pull request #296591 from maud-lv/ml-ac-entra-howto-labels-aspnet-core
Update authentication in snapshots and labels how-to articles
2 parents f605e99 + 12a28cd commit 013bb9c

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: Muksvso
55
ms.author: mubatra
66
ms.service: azure-app-configuration
77
ms.topic: how-to
8-
ms.date: 11/15/2023
8+
ms.date: 03/19/2025
99
---
1010

1111
# Manage and use snapshots
@@ -96,8 +96,8 @@ Edit the call to the `AddAzureAppConfiguration` method, which is often found in
9696
```csharp
9797
configurationBuilder.AddAzureAppConfiguration(options =>
9898
{
99-
options.Connect(Environment.GetEnvironmentVariable("ConnectionString"));
100-
99+
string endpoint = Environment.GetEnvironmentVariable("Endpoint");
100+
options.Connect(new Uri(endpoint), new DefaultAzureCredential());
101101
// Select an existing snapshot by name. This will add all of the key-values from the snapshot to this application's configuration.
102102
options.SelectSnapshot("SnapshotName");
103103

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ ms.devlang: csharp
77
author: maud-lv
88
ms.topic: conceptual
99
ms.custom: devx-track-csharp
10-
ms.date: 02/20/2024
10+
ms.date: 03/19/2025
1111
ms.author: malev
1212

1313
---
1414
# Use labels to provide per-environment configuration values.
1515

16-
Many applications need to use different configurations for different environments. Suppose that an application has a configuration value that defines the connection string to use for its back-end database. The application developers use a different database from the one used in production. The database connection string that the application uses must change as the application moves from development to production.
16+
Many applications need to use different configurations for different environments. Suppose that an application has a configuration value that defines the endpoint to use for its back-end database. The application developers use a different database from the one used in production. The database endpoint that the application uses must change as the application moves from development to production.
1717

1818
In Azure App Configuration, you can use *labels* to define different values for the same key. For example, you can define a single key with different values for development and production. You can specify which label to load when connecting to App Configuration.
1919

@@ -47,17 +47,15 @@ var builder = WebApplication.CreateBuilder(args);
4747

4848
builder.Configuration.AddAzureAppConfiguration(options =>
4949
{
50-
options.Connect(builder.Configuration.GetConnectionString("AppConfig"))
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 connection string. For information storing the connection string 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)