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/concept-disaster-recovery.md
+19-1Lines changed: 19 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,8 @@ Your application loads its configuration from both the primary and secondary sto
24
24
25
25
Technically, your application isn't executing a failover. It's attempting to retrieve the same set of configuration data from two App Configuration stores simultaneously. Arrange your code so that it loads from the secondary store first and then the primary store. This approach ensures that the configuration data in the primary store takes precedence whenever it's available. The following code snippet shows how you can implement this arrangement in the .NET Core CLI:
Notice the `optional` parameter passed into the `AddAzureAppConfiguration` function. When set to `true`, this parameter prevents the application from failing to continue if the function can't load configuration data.
The `ConfigureRefresh` method is used to specify the settings used to update the configuration data with the App Configuration store when a refresh operation is triggered. In order to actually trigger a refresh operation, a refresh middleware needs to be configured for the application to refresh the configuration data when any change occurs.
80
106
81
107
2. Add a *Settings.cs* file that defines and implements a new `Settings` class.
@@ -93,32 +119,85 @@ Before you continue, finish [Create an ASP.NET Core app with App Configuration](
93
119
}
94
120
```
95
121
96
-
3. Open *Startup.cs*, and update the `ConfigureServices` method to bind configuration data to the `Settings` class.
122
+
3. Open *Startup.cs*, and use `IServiceCollection.Configure<T>` in the `ConfigureServices` method to bind configuration data to the `Settings` class.
123
+
124
+
#### [.NET Core 2.x](#tab/core2x)
97
125
98
126
```csharp
99
127
public void ConfigureServices(IServiceCollection services)
4. Update the `Configure` method, adding the `UseAzureAppConfiguration` middleware to allow the configuration settings registered for refresh to be updated while the ASP.NET Core web app continues to receive requests.
146
+
147
+
148
+
#### [.NET Core 2.x](#tab/core2x)
149
+
150
+
```csharp
151
+
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
4. Update the `Configure` method to add a middleware to allow the configuration settings registered for refresh to be updated while the ASP.NET Core web app continues to receive requests.
165
+
#### [.NET Core 3.x](#tab/core3x)
114
166
115
167
```csharp
116
-
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
168
+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
117
169
{
118
-
app.UseAzureAppConfiguration();
119
-
app.UseMvc();
170
+
if (env.IsDevelopment())
171
+
{
172
+
app.UseDeveloperExceptionPage();
173
+
}
174
+
else
175
+
{
176
+
app.UseExceptionHandler("/Home/Error");
177
+
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
The middleware uses the refresh configuration specified in the `AddAzureAppConfiguration` method in `Program.cs` to trigger a refresh for each request received by the ASP.NET Core web app. For each request, a refresh operation is triggered and the client library checks if the cached value for the registered configuration settings have expired. For the cached values that have expired, the values for the settings are updated with the App Configuration store, and the remaining values remain unchanged.
124
203
@@ -135,6 +214,8 @@ Before you continue, finish [Create an ASP.NET Core app with App Configuration](
135
214
136
215
2. Update the `HomeController` class to receive `Settings` through dependency injection, and make use of its values.
137
216
217
+
#### [.NET Core 2.x](#tab/core2x)
218
+
138
219
```csharp
139
220
public class HomeController : Controller
140
221
{
@@ -156,6 +237,37 @@ Before you continue, finish [Create an ASP.NET Core app with App Configuration](
156
237
}
157
238
```
158
239
240
+
#### [.NET Core 3.x](#tab/core3x)
241
+
242
+
```csharp
243
+
public class HomeController : Controller
244
+
{
245
+
private readonly Settings _settings;
246
+
private readonly ILogger<HomeController> _logger;
247
+
248
+
public HomeController(ILogger<HomeController> logger, IOptionsSnapshot<Settings> settings)
0 commit comments