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
The Secret Manager tool stores sensitive data for development work outside of your project tree. This approach helps prevent the accidental sharing of app secrets within source code. For more information on Secret Manager, please see [Safe storage of app secrets in development in ASP.NET Core](https://docs.microsoft.com/aspnet/core/security/app-secrets)
@@ -89,22 +97,22 @@ The Secret Manager tool stores sensitive data for development work outside of yo
89
97
90
98
9. Add a reference to the `Microsoft.Azure.AppConfiguration.AspNetCore` NuGet package by running the following command:
10. Run the following command to restore packages for your project:
96
104
97
-
```CLI
98
-
dotnet restore
105
+
```dotnetcli
106
+
dotnet restore
99
107
```
100
108
11. Add a secret named *ConnectionStrings:AppConfig* to Secret Manager.
101
109
102
110
This secret contains the connection string to access your App Configuration store. Replace the value in the following command with the connection string for your App Configuration store.
103
111
104
112
This command must be executed in the same directory as the *.csproj* file.
105
113
106
-
```CLI
107
-
dotnet user-secrets set ConnectionStrings:AppConfig <your_connection_string>
114
+
```dotnetcli
115
+
dotnet user-secrets set ConnectionStrings:AppConfig <your_connection_string>
108
116
```
109
117
110
118
> [!IMPORTANT]
@@ -125,7 +133,7 @@ The Secret Manager tool stores sensitive data for development work outside of yo
125
133
> [!IMPORTANT]
126
134
> `CreateHostBuilder` replaces `CreateWebHostBuilder` in .NET Core 3.0. Select the correct syntax based on your environment.
127
135
128
-
### Update `CreateWebHostBuilder` for .NET Core 2.x
136
+
#### [.NET Core 2.x](#tab/core2x)
129
137
130
138
```csharp
131
139
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
@@ -138,8 +146,8 @@ The Secret Manager tool stores sensitive data for development work outside of yo
138
146
.UseStartup<Startup>();
139
147
```
140
148
141
-
### Update `CreateHostBuilder` for .NET Core 3.x
142
-
149
+
#### [.NET Core 3.x](#tab/core3x)
150
+
143
151
```csharp
144
152
public static IHostBuilder CreateHostBuilder(string[] args) =>
145
153
Host.CreateDefaultBuilder(args)
@@ -151,8 +159,9 @@ The Secret Manager tool stores sensitive data for development work outside of yo
151
159
})
152
160
.UseStartup<Startup>());
153
161
```
162
+
---
154
163
155
-
1. Navigate to *<app root>/Views/Home* and open *Index.cshtml*. Replace its content with the following code:
164
+
14. Navigate to *<app root>/Views/Home* and open *Index.cshtml*. Replace its content with the following code:
156
165
157
166
```HTML
158
167
@using Microsoft.Extensions.Configuration
@@ -171,7 +180,7 @@ The Secret Manager tool stores sensitive data for development work outside of yo
14. Navigate to *<app root>/Views/Shared* and open *_Layout.cshtml*. Replace its content with the following code:
183
+
15. Navigate to *<app root>/Views/Shared* and open *_Layout.cshtml*. Replace its content with the following code:
175
184
176
185
```HTML
177
186
<!DOCTYPE html>
@@ -200,19 +209,19 @@ The Secret Manager tool stores sensitive data for development work outside of yo
200
209
201
210
## Build and run the app locally
202
211
203
-
15. To build the app using the .NET Core CLI, navigate to the root directory of your application and run the following command in the command shell:
212
+
16. To build the app using the .NET Core CLI, navigate to the root directory of your application and run the following command in the command shell:
204
213
205
-
```CLI
206
-
dotnet build
214
+
```dotnetcli
215
+
dotnet build
207
216
```
208
217
209
-
16. After the build successfully completes, run the following command to run the web app locally:
218
+
17. After the build successfully completes, run the following command to run the web app locally:
210
219
211
-
```CLI
212
-
dotnet run
220
+
```dotnetcli
221
+
dotnet run
213
222
```
214
223
215
-
17. If you're working on your local machine, use a browser to navigate to `http://localhost:5000`. This is the default URL for the web app hosted locally.
224
+
18. If you're working on your local machine, use a browser to navigate to `http://localhost:5000`. This is the default URL for the web app hosted locally.
216
225
217
226
If you're working in the Azure Cloud Shell, select the *Web Preview* button followed by *Configure*.
0 commit comments