Skip to content

Commit e93aa0f

Browse files
remove sentinel key refresh
1 parent 129dbcb commit e93aa0f

File tree

1 file changed

+14
-39
lines changed

1 file changed

+14
-39
lines changed

articles/azure-app-configuration/enable-dynamic-configuration-javascript.md

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Before you continue, finish [Create a JavaScript app with Azure App Configuratio
2121
## Prerequisites
2222

2323
- Finish the quickstart [Create a JavaScript app with Azure App Configuration](./quickstart-javascript-provider.md).
24+
- Update the [`@azure/app-configuration-provider`](https://www.npmjs.com/package/@azure/app-configuration-provider) package to version **2.0.0** or later.
2425

2526
## Add key-values
2627

@@ -29,12 +30,6 @@ Add the following key-value to your Azure App Configuration store. For more info
2930
| Key | Value | Label | Content type |
3031
|----------------|-------------------|-------------|--------------------|
3132
| *message* | *Hello World!* | Leave empty | Leave empty |
32-
| *sentinel* | *1* | Leave empty | Leave empty |
33-
34-
A *sentinel key* is a key that you update after you complete the change of all other keys. Your app monitors the sentinel key. When a change is detected, your app refreshes all configuration values. This approach helps to ensure the consistency of configuration in your app and reduces the overall number of requests made to your Azure App Configuration store, compared to monitoring all keys for changes.
35-
36-
> [!NOTE]
37-
> If you use version **2.0.0-preview.2** or later of [@azure/app-configuration-provider](https://www.npmjs.com/package/@azure/app-configuration-provider), the App Configuration provider will by default refresh based on monitoring the key-value collection. Sentinel key is not needed for refresh. For more information, please go to [Monitor key-value collection for refresh](#monitor-key-value-collection-for-refresh)
3833

3934
## Console applications
4035

@@ -52,10 +47,9 @@ You can connect to App Configuration using either Microsoft Entra ID (recommende
5247
```javascript
5348
// Connecting to Azure App Configuration using endpoint and token credential
5449
const appConfig = await load(endpoint, credential, {
55-
// Setting up to refresh when the sentinel key is changed
50+
// Enabling the dynamic refresh
5651
refreshOptions: {
57-
enabled: true,
58-
watchedSettings: [{ key: "sentinel" }] // Watch for changes to the key "sentinel" and refreshes the configuration when it changes
52+
enabled: true
5953
}
6054
});
6155
```
@@ -68,10 +62,9 @@ You can connect to App Configuration using either Microsoft Entra ID (recommende
6862
```javascript
6963
// Connecting to Azure App Configuration using endpoint and token credential
7064
const appConfig = await load(endpoint, credential, {
71-
// Setting up to refresh when the sentinel key is changed
65+
// Enabling the dynamic refresh
7266
refreshOptions: {
73-
enabled: true,
74-
watchedSettings: [{ key: "sentinel" }] // Watch for changes to the key "sentinel" and refreshes the configuration when it changes
67+
enabled: true
7568
}
7669
});
7770

@@ -86,6 +79,9 @@ You can connect to App Configuration using either Microsoft Entra ID (recommende
8679
```
8780
---
8881

82+
> [!NOTE]
83+
> If you get the error: "Refresh is enabled but no watched settings are specified.", please update the [`@azure/app-configuration-provider`](https://www.npmjs.com/package/@azure/app-configuration-provider) package to version **2.0.0** or later.
84+
8985
1. Setting up `refreshOptions` alone won't automatically refresh the configuration. You need to call the `refresh` 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 message or an order, or inside an iteration where you perform a complex task. Alternatively, you can use a timer if your application is always active. In this example, `refresh` is called in a loop for demonstration purposes. 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.
9086

9187
Add the following code to poll configuration changes of watched key-values.
@@ -128,10 +124,9 @@ You can connect to App Configuration using either Microsoft Entra ID (recommende
128124
async function run() {
129125
// Connecting to Azure App Configuration using endpoint and token credential
130126
const appConfig = await load(endpoint, credential, {
131-
// Setting up to refresh when the sentinel key is changed
127+
// Enabling the dynamic refresh
132128
refreshOptions: {
133-
enabled: true,
134-
watchedSettings: [{ key: "sentinel" }] // Watch for changes to the key "sentinel" and refreshes the configuration when it changes
129+
enabled: true
135130
}
136131
});
137132
@@ -157,10 +152,9 @@ You can connect to App Configuration using either Microsoft Entra ID (recommende
157152
async function run() {
158153
// Connecting to Azure App Configuration using endpoint and token credential
159154
const appConfig = await load(endpoint, credential, {
160-
// Setting up to refresh when the sentinel key is changed
155+
// Enabling the dynamic refresh
161156
refreshOptions: {
162-
enabled: true,
163-
watchedSettings: [{ key: "sentinel" }] // Watch for changes to the key "sentinel" and refreshes the configuration when it changes
157+
enabled: true
164158
}
165159
});
166160
@@ -200,36 +194,18 @@ You can connect to App Configuration using either Microsoft Entra ID (recommende
200194
```
201195
It continues to print "Hello World!" in a new line every 5 seconds.
202196

203-
1. Update the following key-values to the Azure App Configuration store. Update value of the key `message` first and then `sentinel`.
197+
1. Update the following key-values to the Azure App Configuration store. Update value of the key `message`.
204198

205199
| Key | Value | Label | Content type |
206200
|----------------|---------------------------|-------------|--------------------|
207201
| *message* | *Hello World - Updated!* | Leave empty | Leave empty |
208-
| *sentinel* | *2* | Leave empty | Leave empty |
209202

210203
1. Once the values are updated, the updated value is printed after the refresh interval.
211204

212205
```console
213206
Hello World - Updated!
214207
```
215208

216-
## Monitor key-value collection for refresh
217-
218-
Instead of monitoring any sentinel key, the App Configuration provider supports for monitoring all selected key-values. Configuration will be refreshed if any of key-values are updated. Watching the sentinel key for refresh helps ensure data integrity of configuration changes, but it is now optional. This behavior is activated when you enable the refresh but do not specify any watched keys in `AzureAppConfigurationOptions.refreshOptions`
219-
220-
```javascript
221-
const appConfig = await load(endpoint, credential, {
222-
refreshOptions: {
223-
enabled: true,
224-
// watchedSettings: []
225-
}
226-
});
227-
228-
appConfig.refresh(); // Configuration will be refreshed if any of key-values are updated.
229-
```
230-
231-
This feature is available for version **2.0.0-preview.2** or later of [@azure/app-configuration-provider](https://www.npmjs.com/package/@azure/app-configuration-provider).
232-
233209
## Server application
234210

235211
The following example shows how to update an existing http server to use refreshable configuration values.
@@ -284,8 +260,7 @@ The following example shows how to update an existing http server to use refresh
284260
appConfig = await load(endpoint, credential, {
285261
refreshOptions: {
286262
enabled: true,
287-
// without registering any watched setting/sentinel key, the provider will monitor the key-value collection for refresh
288-
refreshIntervalInMs: 15_000 // Set the refresh interval
263+
refreshIntervalInMs: 15_000 // set the refresh interval
289264
}
290265
});
291266
}

0 commit comments

Comments
 (0)