Skip to content

Commit 5ca2c60

Browse files
wip
1 parent 6e57f2e commit 5ca2c60

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

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

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ type AzureAppConfiguration = {
6868
} & IGettable & ReadonlyMap<string, any> & IConfigurationObject;
6969
```
7070

71-
For more information about `refresh` and `onRefresh` methods, see the [Dynamic refresh](#dynamic-refresh) section.
71+
For more information about `refresh` and `onRefresh` methods, see the [Configuration refresh](#configuration-refresh) section.
7272

7373
### Consume configuration
7474

@@ -196,9 +196,42 @@ const settings = await load(endpoint, credential, {
196196
});
197197
```
198198

199-
## Dynamic refresh
199+
## Configuration refresh
200200

201-
### Watch sentinel key for refresh (Deprecated)
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.
202+
203+
```typescript
204+
const settings = await load(endpoint, credential, {
205+
refreshOptions: {
206+
enabled: true
207+
}
208+
});
209+
// this call s not blocking, the configuration will be updated asynchronously
210+
settings.refresh();
211+
```
212+
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.
214+
215+
```typescript
216+
const settings = await load(endpoint, credential, {
217+
refreshOptions: {
218+
enabled: true
219+
}
220+
});
221+
222+
const server = express();
223+
// Use an express middleware to achieve request-driven configuration refresh
224+
server.use((req, res, next) => {
225+
settings.refresh();
226+
next();
227+
})
228+
```
229+
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.
233+
234+
For information about refresh configuration, please go to [Use dynamic configuration in JavaScript](./enable-dynamic-configuration-javascript.md).
202235

203236
## Feature flag
204237

@@ -235,4 +268,4 @@ For information about use geo-replication, please go to [Enable geo-replication]
235268
To learn how to use JavaScript configuration provider, continue to the following tutorials.
236269

237270
> [!div class="nextstepaction"]
238-
> [Use dynamic configuration in JavaScript](./enable-dynamic-configuration-javascript.md)
271+
> [Use dynamic configuration in JavaScript](./enable-dynamic-configuration-javascript.md)

0 commit comments

Comments
 (0)