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/quickstart-aspnet-core-app.md
+70-9Lines changed: 70 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,6 +71,57 @@ dotnet new mvc --no-https --output TestAppConfig
71
71
72
72
Access this secret using the .NET Core Configuration API. A colon (`:`) works in the configuration name with the Configuration API on all supported platforms. For more information, see [Configuration keys and values](/aspnet/core/fundamentals/configuration#configuration-keys-and-values).
73
73
74
+
> [!IMPORTANT]
75
+
> `CreateHostBuilder` replaces `CreateWebHostBuilder` in .NET Core 3.x. Select the correct syntax based on your environment.
76
+
77
+
#### [.NET 6.x](#tab/core6x)
78
+
79
+
1. In *Program.cs*, and replace its content with the following code:
80
+
```csharp
81
+
var builder = WebApplication.CreateBuilder(args);
82
+
builder.Host.ConfigureAppConfiguration(builder =>
83
+
{
84
+
builder.AddAzureAppConfiguration(options =>
85
+
{
86
+
//Connect to your App Config Store using a connection string
This will connect to your App Configuration Store using a connection string and load all keys that have the *TestApp* prefix from a previous step.
121
+
122
+
123
+
#### [.NET 5.x](#tab/core5x)
124
+
74
125
1. In *Program.cs*, add a reference to the .NET Core Configuration API namespace:
75
126
76
127
```csharp
@@ -79,11 +130,6 @@ dotnet new mvc --no-https --output TestAppConfig
79
130
80
131
1. Update the `CreateWebHostBuilder` method to use App Configuration by calling the `AddAzureAppConfiguration` method.
81
132
82
-
> [!IMPORTANT]
83
-
> `CreateHostBuilder` replaces `CreateWebHostBuilder` in .NET Core 3.x. Select the correct syntax based on your environment.
84
-
85
-
#### [.NET 5.x](#tab/core5x)
86
-
87
133
```csharp
88
134
public static IHostBuilder CreateHostBuilder(string[] args) =>
89
135
Host.CreateDefaultBuilder(args)
@@ -95,7 +141,14 @@ dotnet new mvc --no-https --output TestAppConfig
95
141
config.AddAzureAppConfiguration(connection);
96
142
}).UseStartup<Startup>());
97
143
```
98
-
#### [.NET Core 3.x](#tab/core3x)
144
+
#### [.NET Core 3.x](#tab/core3x)
145
+
1. In *Program.cs*, add a reference to the .NET Core Configuration API namespace:
146
+
147
+
```csharp
148
+
using Microsoft.Extensions.Configuration;
149
+
```
150
+
151
+
1. Update the `CreateWebHostBuilder` method to use App Configuration by calling the `AddAzureAppConfiguration` method.
99
152
100
153
```csharp
101
154
public static IHostBuilder CreateHostBuilder(string[] args) =>
@@ -109,7 +162,15 @@ dotnet new mvc --no-https --output TestAppConfig
109
162
}).UseStartup<Startup>());
110
163
```
111
164
112
-
#### [.NET Core 2.x](#tab/core2x)
165
+
#### [.NET Core 2.x](#tab/core2x)
166
+
167
+
1. In *Program.cs*, add a reference to the .NET Core Configuration API namespace:
168
+
169
+
```csharp
170
+
using Microsoft.Extensions.Configuration;
171
+
```
172
+
173
+
1. Update the `CreateWebHostBuilder` method to use App Configuration by calling the `AddAzureAppConfiguration` method.
113
174
114
175
```csharp
115
176
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
@@ -123,7 +184,7 @@ dotnet new mvc --no-https --output TestAppConfig
123
184
.UseStartup<Startup>();
124
185
```
125
186
126
-
---
187
+
---
127
188
128
189
With the preceding change, the [configuration provider for App Configuration](/dotnet/api/Microsoft.Extensions.Configuration.AzureAppConfiguration) has been registered with the .NET Core Configuration API.
129
190
@@ -171,7 +232,7 @@ In the preceding code, the App Configuration store's keys are used as follows:
171
232
dotnet run
172
233
```
173
234
174
-
1. If you're working on your local machine, use a browser to navigate to `http://localhost:5000`. This address is the default URL for the locally hosted web app. If you're working in the Azure Cloud Shell, select the **Web Preview** button followed by **Configure**.
235
+
1. If you're working on your local machine, use a browser to navigate to `http://localhost:5000` or as specified in the command output. This address is the default URL for the locally hosted web app. If you're working in the Azure Cloud Shell, select the **Web Preview** button followed by **Configure**.
175
236
176
237

Copy file name to clipboardExpand all lines: includes/azure-app-configuration-add-secret-manager.md
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,28 @@
2
2
3
3
A tool called Secret Manager stores sensitive data for development work outside of your project tree. This approach helps prevent the accidental sharing of app secrets within source code. Complete the following steps to enable the use of Secret Manager in the ASP.NET Core project:
4
4
5
+
#### [.NET 6.x](#tab/core6x)
6
+
7
+
Navigate to the project's root directory, and run the following command to enable secrets storage in the project:
8
+
9
+
```dotnetcli
10
+
dotnet user-secrets init
11
+
```
12
+
13
+
A `UserSecretsId` element containing a GUID is added to the *.csproj* file:
0 commit comments