Skip to content

Commit 41f907b

Browse files
authored
Update howto-labels-aspnet-core.md
Removed indenting that was causing formatting problems.
1 parent a25e384 commit 41f907b

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

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

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Use per-environment configuration
33
titleSuffix: Azure App Configuration
4-
description: Use labels to provide per-environment configuration values
4+
description: Use labels to provide per-environment configuration values.
55
ms.service: azure-app-configuration
66
author: lisaguthrie
77
ms.topic: conceptual
@@ -19,10 +19,10 @@ To demonstrate this functionality, you'll modify the web app created in [Quickst
1919

2020
## Specify a label when adding a configuration value
2121

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**.
2323

24-
> [!div class="mx-imgBorder"]
25-
> ![Add Value menu item](media/labels-add-value.png)
24+
> [!div class="mx-imgBorder"]
25+
> ![Add Value menu item](media/labels-add-value.png)
2626
2727
On the **Add Value** screen, enter a **Value** of **red** and a **Label** of **Development**. Leave **Content type** empty. Select **Apply**.
2828

@@ -34,27 +34,27 @@ In the previous section, you created a different configuration value for the dev
3434

3535
Load configuration values with the label corresponding to the current environment by passing the environment name into the `Select` method:
3636

37-
```csharp
38-
public static IHostBuilder CreateHostBuilder(string[] args) =>
39-
Host.CreateDefaultBuilder(args)
40-
.ConfigureWebHostDefaults(webBuilder =>
41-
webBuilder.ConfigureAppConfiguration((hostingContext, config) =>
42-
{
43-
var settings = config.Build();
44-
config.AddAzureAppConfiguration(options =>
45-
options
46-
.Connect(Environment.GetEnvironmentVariable("AppConfigConnectionString"))
47-
// Load configuration values with no label
48-
.Select(KeyFilter.Any, LabelFilter.Null)
49-
// Override with any configuration values specific to current hosting env
50-
.Select(KeyFilter.Any, hostingContext.HostingEnvironment.EnvironmentName)
51-
);
52-
})
53-
.UseStartup<Startup>());
54-
```
37+
```csharp
38+
public static IHostBuilder CreateHostBuilder(string[] args) =>
39+
Host.CreateDefaultBuilder(args)
40+
.ConfigureWebHostDefaults(webBuilder =>
41+
webBuilder.ConfigureAppConfiguration((hostingContext, config) =>
42+
{
43+
var settings = config.Build();
44+
config.AddAzureAppConfiguration(options =>
45+
options
46+
.Connect(Environment.GetEnvironmentVariable("AppConfigConnectionString"))
47+
// Load configuration values with no label
48+
.Select(KeyFilter.Any, LabelFilter.Null)
49+
// Override with any configuration values specific to current hosting env
50+
.Select(KeyFilter.Any, hostingContext.HostingEnvironment.EnvironmentName)
51+
);
52+
})
53+
.UseStartup<Startup>());
54+
```
5555

5656
> [!IMPORTANT]
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.
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.
5858
5959
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.
6060

@@ -64,20 +64,20 @@ Open the `launchSettings.json` file under the `Properties` directory. Find the `
6464

6565
With the new values set, build and run your application.
6666

67-
```dotnetcli
68-
dotnet build
69-
dotnet run
70-
```
67+
```dotnetcli
68+
dotnet build
69+
dotnet run
70+
```
7171

7272
Use a web browser to go to `http://localhost:5000`. You'll notice that the font color is black.
7373

74-
![Web application running with production configuration](media/labels-website-prod.png)
74+
![Web application running with production configuration](media/labels-website-prod.png)
7575

7676
Update `launchSettings.json` to set the `ASPNETCORE_ENVIRONMENT` variable to `Development`. Run `dotnet run` again.
7777

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.
7979

80-
![Web application running with development configuration](media/labels-website-dev.png)
80+
![Web application running with development configuration](media/labels-website-dev.png)
8181

8282
## Next steps
8383

0 commit comments

Comments
 (0)