You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-app-configuration/howto-labels-aspnet-core.md
+30-30Lines changed: 30 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: Use per-environment configuration
3
3
titleSuffix: Azure App Configuration
4
-
description: Use labels to provide per-environment configuration values
4
+
description: Use labels to provide per-environment configuration values.
5
5
ms.service: azure-app-configuration
6
6
author: lisaguthrie
7
7
ms.topic: conceptual
@@ -19,10 +19,10 @@ To demonstrate this functionality, you'll modify the web app created in [Quickst
19
19
20
20
## Specify a label when adding a configuration value
21
21
22
-
In the Azure portal, go to **Configuration Explorer** and find the *TestApp:Settings:FontColor* key that you created in the quickstart. Select its context menu and then click**Add Value**.
22
+
In the Azure portal, go to **Configuration Explorer** and find the *TestApp:Settings:FontColor* key that you created in the quickstart. Select its context menu and then select**Add Value**.
23
23
24
-
> [!div class="mx-imgBorder"]
25
-
> 
24
+
> [!div class="mx-imgBorder"]
25
+
> 
26
26
27
27
On the **Add Value** screen, enter a **Value** of **red** and a **Label** of **Development**. Leave **Content type** empty. Select **Apply**.
28
28
@@ -34,27 +34,27 @@ In the previous section, you created a different configuration value for the dev
34
34
35
35
Load configuration values with the label corresponding to the current environment by passing the environment name into the `Select` method:
36
36
37
-
```csharp
38
-
public static IHostBuilder CreateHostBuilder(string[] args) =>
> The preceding code snippet loads the App Configuration connection string from an environment variable named `AppConfigConnectionString`. Be sure that this environment variable is set properly.
57
+
> The preceding code snippet loads the App Configuration connection string from an environment variable named `AppConfigConnectionString`. Be sure that this environment variable is set properly.
58
58
59
59
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.
60
60
@@ -64,20 +64,20 @@ Open the `launchSettings.json` file under the `Properties` directory. Find the `
64
64
65
65
With the new values set, build and run your application.
66
66
67
-
```dotnetcli
68
-
dotnet build
69
-
dotnet run
70
-
```
67
+
```dotnetcli
68
+
dotnet build
69
+
dotnet run
70
+
```
71
71
72
72
Use a web browser to go to `http://localhost:5000`. You'll notice that the font color is black.
73
73
74
-

74
+

75
75
76
76
Update `launchSettings.json` to set the `ASPNETCORE_ENVIRONMENT` variable to `Development`. Run `dotnet run` again.
77
77
78
-
You'll notice that the font color is now red. This is because the application now uses the value of `TestApp:Settings:FontColor` that has the `Development` label. All other configuration values remain the same as their production values.
78
+
You'll notice that the font color is now red. This is because the application now uses the value of `TestApp:Settings:FontColor` that has the `Development` label. All other configuration values remain the same as their production values.
79
79
80
-

80
+

0 commit comments