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
+18Lines changed: 18 additions & 0 deletions
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,24 +119,33 @@ 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.
112
146
113
-
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.
147
+
148
+
#### [.NET Core 2.x](#tab/core2x)
114
149
115
150
```csharp
116
151
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
@@ -119,6 +154,43 @@ Before you continue, finish [Create an ASP.NET Core app with App Configuration](
119
154
app.UseMvc();
120
155
}
121
156
```
157
+
158
+
#### [.NET Core 3.x](#tab/core3x)
159
+
160
+
```csharp
161
+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
162
+
{
163
+
if (env.IsDevelopment())
164
+
{
165
+
app.UseDeveloperExceptionPage();
166
+
}
167
+
else
168
+
{
169
+
app.UseExceptionHandler("/Home/Error");
170
+
// 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
196
@@ -135,6 +207,8 @@ Before you continue, finish [Create an ASP.NET Core app with App Configuration](
135
207
136
208
2. Update the `HomeController` class to receive `Settings` through dependency injection, and make use of its values.
137
209
210
+
#### [.NET Core 2.x](#tab/core2x)
211
+
138
212
```csharp
139
213
public class HomeController : Controller
140
214
{
@@ -156,6 +230,37 @@ Before you continue, finish [Create an ASP.NET Core app with App Configuration](
156
230
}
157
231
```
158
232
233
+
#### [.NET Core 3.x](#tab/core3x)
234
+
235
+
```csharp
236
+
public class HomeController : Controller
237
+
{
238
+
private readonly Settings _settings;
239
+
private readonly ILogger<HomeController> _logger;
240
+
241
+
public HomeController(ILogger<HomeController> logger, IOptionsSnapshot<Settings> settings)
0 commit comments