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
Secret Manager stores the secret outside of your project tree, which helps prevent the accidental sharing of secrets within source code. It's used only to test the web app locally. When the app is deployed to Azure like [App Service](../app-service/overview.md), use the *Connection strings*, *Application settings* or environment variables to store the connection string. Alternatively, to avoid connection strings all together, you can [connect to App Configuration using managed identities](./howto-integrate-azure-managed-service-identity.md) or your other [Azure AD identities](./concept-enable-rbac.md).
77
80
78
-
1. Open *Program.cs*, and add Azure App Configuration as an extra configuration source by calling the `AddAzureAppConfiguration` method.
81
+
1. Open *Program.cs* and add Azure App Configuration as an extra configuration source by calling the `AddAzureAppConfiguration` method.
This code will connect to your App Configuration store using a connection string and load *all* key-values that have *no labels*. For more information on the App Configuration provider, see the [App Configuration provider API reference](/dotnet/api/Microsoft.Extensions.Configuration.AzureAppConfiguration).
In this example, you'll update a web page to display its content using the settings you configured in your App Configuration store.
122
128
123
-
1. Add a *Settings.cs* file at the root of your project directory. It defines a strongly typed `Settings` class for the configuration you're going to use. Replace the namespace with the name of your project.
129
+
1. Add a *Settings.cs* file at the root of your project directory. It defines a strongly typed `Settings` class for the configuration you're going to use. Replace the namespace with the name of your project.
124
130
125
131
```csharp
126
132
namespace TestAppConfig
@@ -138,9 +144,12 @@ In this example, you'll update a web page to display its content using the setti
138
144
1. Bind the `TestApp:Settings` section in configuration to the `Settings` object.
139
145
140
146
#### [.NET 6.x](#tab/core6x)
141
-
Update *Program.cs* with the following code.
147
+
148
+
Update *Program.cs* with the following code and add the `TestAppConfig` namespace at the beginning of the file.
142
149
143
150
```csharp
151
+
using TestAppConfig;
152
+
144
153
// Existing code in Program.cs
145
154
// ... ...
146
155
@@ -154,10 +163,11 @@ In this example, you'll update a web page to display its content using the setti
154
163
// The rest of existing code in program.cs
155
164
// ... ...
156
165
```
157
-
166
+
158
167
#### [.NET Core 3.x](#tab/core3x)
168
+
159
169
Open *Startup.cs* and update the `ConfigureServices` method.
160
-
170
+
161
171
```csharp
162
172
public void ConfigureServices(IServiceCollection services)
163
173
{
@@ -167,9 +177,10 @@ In this example, you'll update a web page to display its content using the setti
1. Open *Index.cshtml.cs* in the *Pages* directory, and update the `IndexModel` class with the following code. Add `using Microsoft.Extensions.Options` namespace at the beginning of the file, if it's not already there.
183
+
1. Open *Index.cshtml.cs* in the *Pages* directory, and update the `IndexModel` class with the following code. Add the `using Microsoft.Extensions.Options` namespace at the beginning of the file, if it's not already there.
173
184
174
185
```csharp
175
186
public class IndexModel : PageModel
@@ -223,14 +234,14 @@ In this example, you'll update a web page to display its content using the setti
223
234
dotnet run
224
235
```
225
236
226
-
1. Open a browser and navigate to the URL the app is listening on, as specified in the command output. It looks like `https://localhost:5001`.
237
+
1. The output of the `dotnet run` command contains two URLs. Open a browser and navigate to either one of these URLs to access your application. For example: `https://localhost:5001`.
227
238
228
239
If you're working in the Azure Cloud Shell, select the *Web Preview* button followed by *Configure*. When prompted to configure the port for preview, enter *5000*, and select *Open and browse*.
229
240
230
-

241
+
:::image type="content" source="./media/quickstarts/cloud-shell-web-preview.png" alt-text="Screenshot of Azure Cloud Shell. Locate Web Preview.":::
:::image type="content" source="./media/quickstarts/aspnet-core-app-launch-local-navbar.png" alt-text="Screenshot of the browser.Launching quickstart app locally.":::
234
245
235
246
## Clean up resources
236
247
@@ -248,4 +259,4 @@ In this quickstart, you:
248
259
To learn how to configure your ASP.NET Core web app to dynamically refresh configuration settings, continue to the next tutorial.
0 commit comments