Skip to content

Commit ada8078

Browse files
Adding Connection strings and feedback
1 parent 9b69fce commit ada8078

File tree

1 file changed

+18
-23
lines changed

1 file changed

+18
-23
lines changed

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

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ In this quickstart, you'll use Azure App Configuration to centralize storage and
2323
> [!TIP]
2424
> The Azure Cloud Shell is a free, interactive shell that you can use to run the command line instructions in this article. It has common Azure tools preinstalled, including the .NET Core SDK. If you're logged in to your Azure subscription, launch your [Azure Cloud Shell](https://shell.azure.com) from shell.azure.com. You can learn more about Azure Cloud Shell by [reading our documentation](../cloud-shell/overview.md)
2525
26-
## Create an App Configuration store
26+
## Create an App Configuration store
2727

2828
[!INCLUDE[Azure App Configuration resource creation steps](../../includes/azure-app-configuration-create.md)]
2929

@@ -78,22 +78,19 @@ dotnet new mvc --no-https --output TestAppConfig
7878
7979
```csharp
8080
var builder = WebApplication.CreateBuilder(args);
81+
//Retrieve the Connection String from the secrets manager
82+
var connectionString = builder.Configuration["AppConfig"];
83+
8184
builder.Host.ConfigureAppConfiguration(builder =>
82-
{
83-
builder.AddAzureAppConfiguration(options =>
84-
{
85-
//Connect to your App Config Store using a connection string
86-
options.Connect(Environment.GetEnvironmentVariable("AppConfig"))
87-
// Load all keys that start with `TestApp:` and have no label
88-
.Select("TestApp:*");
89-
});
90-
})
91-
.ConfigureServices(services =>
92-
{
93-
// Make Azure App Configuration services available through dependency injection
94-
services.AddAzureAppConfiguration()
95-
.AddControllersWithViews();
96-
});
85+
{
86+
//Connect to your App Config Store using the connection string
87+
builder.AddAzureAppConfiguration(connectionString);
88+
})
89+
.ConfigureServices(services =>
90+
{
91+
services.AddControllersWithViews();
92+
});
93+
9794
9895
var app = builder.Build();
9996
@@ -102,9 +99,7 @@ dotnet new mvc --no-https --output TestAppConfig
10299
{
103100
app.UseExceptionHandler("/Home/Error");
104101
}
105-
app.UseStaticFiles();
106-
107-
app.UseAzureAppConfiguration();
102+
app.UseStaticFiles();
108103
109104
app.UseRouting();
110105
@@ -128,9 +123,6 @@ dotnet new mvc --no-https --output TestAppConfig
128123
using Microsoft.Extensions.Configuration;
129124
```
130125
131-
> [!IMPORTANT]
132-
> `CreateHostBuilder` in .NET 5.x replaces `CreateWebHostBuilder` in .NET Core 3.x.
133-
134126
1. Update the `CreateWebHostBuilder` method to use App Configuration by calling the `AddAzureAppConfiguration` method.
135127
136128
```csharp
@@ -151,7 +143,10 @@ dotnet new mvc --no-https --output TestAppConfig
151143
using Microsoft.Extensions.Configuration;
152144
```
153145
154-
1. Update the `CreateWebHostBuilder` method to use App Configuration by calling the `AddAzureAppConfiguration` method.
146+
> [!IMPORTANT]
147+
> `CreateHostBuilder` in .NET 3.x replaces `CreateWebHostBuilder` in .NET Core 2.x.
148+
149+
1. Update the `CreateHostBuilder` method to use App Configuration by calling the `AddAzureAppConfiguration` method.
155150
156151
```csharp
157152
public static IHostBuilder CreateHostBuilder(string[] args) =>

0 commit comments

Comments
 (0)