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).
80
80
81
-
1. Open *Program.cs*, add the `using TestAppConfig;` statement 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.
82
82
83
83
#### [.NET 6.x](#tab/core6x)
84
84
85
85
```csharp
86
86
// Existing code in Program.cs
87
87
// ... ...
88
88
89
-
using TestAppConfig;
90
-
91
89
var builder = WebApplication.CreateBuilder(args);
92
90
93
91
// Retrieve the connection string
@@ -150,9 +148,11 @@ In this example, you'll update a web page to display its content using the setti
150
148
151
149
#### [.NET 6.x](#tab/core6x)
152
150
153
-
Update *Program.cs* with the following code.
151
+
Update *Program.cs* with the following code and add the `TestAppConfig` namespace at the beginning of the file.
154
152
155
153
```csharp
154
+
using TestAppConfig;
155
+
156
156
// Existing code in Program.cs
157
157
// ... ...
158
158
@@ -183,25 +183,26 @@ In this example, you'll update a web page to display its content using the setti
183
183
184
184
---
185
185
186
-
1. Open *Index.cshtml.cs* in the *Pages* directory. Add the [Microsoft.Extensions.Options](/dotnet/api/microsoft.extensions.options) namespace and update the `IndexModel` class with the following code.
186
+
1. Open *Index.cshtml.cs* in the *Pages* directoryand update it with the following code.
187
187
188
188
```csharp
189
-
// Existing code in Index.cshtml.cs
190
-
// ... ...
191
-
189
+
using Microsoft.AspNetCore.Mvc.RazorPages;
192
190
using Microsoft.Extensions.Options;
193
191
194
-
public class IndexModel : PageModel
192
+
namespace TestAppConfig.Pages
195
193
{
196
-
private readonly ILogger<IndexModel> _logger;
197
-
198
-
public Settings Settings { get; }
199
-
200
-
public IndexModel(IOptionsSnapshot<Settings> options, ILogger<IndexModel> logger)
201
-
{
202
-
Settings = options.Value;
203
-
_logger = logger;
204
-
}
194
+
public class IndexModel : PageModel
195
+
{
196
+
private readonly ILogger<IndexModel> _logger;
197
+
198
+
public Settings Settings { get; }
199
+
200
+
public IndexModel(IOptionsSnapshot<Settings> options, ILogger<IndexModel> logger)
201
+
{
202
+
Settings = options. Value;
203
+
_logger = logger;
204
+
}
205
+
}
205
206
}
206
207
```
207
208
@@ -249,7 +250,7 @@ In this example, you'll update a web page to display its content using the setti
249
250
:::image type="content" source="./media/quickstarts/cloud-shell-web-preview.png" alt-text="Screenshot of Azure Cloud Shell. Locate Web Preview.":::
250
251
251
252
The web page looks like this:
252
-
:::image type="content" source="./media/quickstarts/aspnet-core-app-launch-local-navbar.png" alt-text="Screenshot of the browser.Launching quickstart app locally.":::
253
+
:::image type="content" source="./media/quickstarts/aspnet-core-app-launch-local-navbar.png" alt-text="Screenshot of the browser.Launching quickstart app locally.":::
0 commit comments