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/enable-dynamic-configuration-dotnet-core.md
+54Lines changed: 54 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -130,6 +130,60 @@ In the `ConfigureRefresh` method, a key within your App Configuration store is r
130
130
131
131
Calling the `ConfigureRefresh` method alone won't cause the configuration to refresh automatically. You call the `TryRefreshAsync` method from the interface `IConfigurationRefresher` to trigger a refresh. This design is to avoid phantom requests sent to App Configuration even when your application is idle. You'll want to include the `TryRefreshAsync` call where you consider your application active. For example, it can be when you process an incoming message, an order, or an iteration of a complex task. It can also be in a timer if your application is active all the time. In this example, you call `TryRefreshAsync` every time you press the Enter key. Even if the call `TryRefreshAsync` fails for any reason, your application continues to use the cached configuration. Another attempt is made when the configured cache expiration time has passed and the `TryRefreshAsync` call is triggered by your application activity again. Calling `TryRefreshAsync` is a no-op before the configured cache expiration time elapses, so its performance impact is minimal, even if it's called frequently.
132
132
133
+
### Configuration refresh using dependency injection
134
+
135
+
In the previous code, you're manually saving an instance of `IConfigurationRefresher` to invoke `TryRefreshAsync`. Alternatively, if you're using dependency injection to resolve your services, you can reference the following steps.
136
+
137
+
1. Register the required App Configuration services by invoking `AddAzureAppConfiguration` on your `IServiceCollection`.
138
+
139
+
#### [.NET 6.0+](#tab/core6x)
140
+
Add the following code to *Program.cs*.
141
+
142
+
```csharp
143
+
// Existing code in Program.cs
144
+
// ... ...
145
+
146
+
// Add Azure App Configuration services to IServiceCollection
0 commit comments