Skip to content

Commit 6835486

Browse files
finished
1 parent 5ca2c60 commit 6835486

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

articles/azure-app-configuration/reference-javascript-provider.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -198,40 +198,38 @@ const settings = await load(endpoint, credential, {
198198

199199
## Configuration refresh
200200

201-
You can enable the dynamic refresh for the configuration through the `AzureAppConfigurationOptions.refreshOptions` property. Dynamic refresh for the configurations lets you pull their latest values from the App Configuration store without having to restart the application.
201+
Dynamic refresh for the configurations lets you pull their latest values from the App Configuration store without having to restart the application.You can set `AzureAppConfigurationOptions.refreshOptions` to enable the refresh and configure refresh options. The loaded configuration will be updated when any change of selected key-values is detected on the server. By default, a refresh interval of 30 seconds is used, but you can override it with the `refreshIntervalInMs` property.
202202

203203
```typescript
204204
const settings = await load(endpoint, credential, {
205205
refreshOptions: {
206-
enabled: true
206+
enabled: true,
207+
refreshIntervalInMs: 15_000
207208
}
208209
});
209-
// this call s not blocking, the configuration will be updated asynchronously
210+
```
211+
212+
Setting up `refreshOptions` alone won't automatically refresh the configuration. You need to call the `refresh` method on `AzureAppConfiguration` instance returned by the `load` method to trigger a refresh.
213+
214+
``` typescript
215+
// this call is not blocking, the configuration will be updated asynchronously
210216
settings.refresh();
211217
```
212218

213-
Setting up `refreshOptions` alone won't automatically refresh the configuration. You need to call the `refresh` method on `AzureAppConfiguration` instance returned by the `load` method to trigger a refresh. This design prevents unnecessary requests to App Configuration when your application is idle. You should include the `refresh` call where your application activity occurs. This is known as **activity-driven configuration refresh**. For example, you can call `refresh` when processing an incoming request or inside an iteration where you perform a complex task. Calling `refresh` is a no-op before the configured refresh interval elapses, so its performance impact is minimal even if it's called frequently.
219+
This design prevents unnecessary requests to App Configuration when your application is idle. You should include the `refresh` call where your application activity occurs. This is known as **activity-driven configuration refresh**. For example, you can call `refresh` when processing an incoming request or inside an iteration where you perform a complex task.
214220

215221
```typescript
216-
const settings = await load(endpoint, credential, {
217-
refreshOptions: {
218-
enabled: true
219-
}
220-
});
221-
222222
const server = express();
223-
// Use an express middleware to achieve request-driven configuration refresh
223+
// Use an express middleware to refresh configuration whenever a request comes in
224224
server.use((req, res, next) => {
225225
settings.refresh();
226226
next();
227227
})
228228
```
229229

230-
By default, a refresh interval of 30 seconds is used, but you can override it with the `refreshIntervalInMs` property.
231-
232-
This is done by providing a refresh_on to the provider, which is a list of key(s) that will be watched for changes, and when they do change a refresh can happen. refresh_interval is the period of time in seconds between refreshes. on_refresh_success is a callback that will be called only if a change is detected and no error happens. on_refresh_error is a callback that will be called when a refresh fails.
230+
Even if the refresh call fails for any reason, your application will continue to use the cached configuration. Another attempt will be made when the configured refresh interval has passed and the refresh call is triggered by your application activity. Calling `refresh` is a no-op before the configured refresh interval elapses, so its performance impact is minimal even if it's called frequently.
233231

234-
For information about refresh configuration, please go to [Use dynamic configuration in JavaScript](./enable-dynamic-configuration-javascript.md).
232+
For more information about refresh configuration, please go to [Use dynamic configuration in JavaScript](./enable-dynamic-configuration-javascript.md).
235233

236234
## Feature flag
237235

0 commit comments

Comments
 (0)