Skip to content

Commit 98a3c15

Browse files
add dynamic refresh for feature flag
1 parent 6da3b9b commit 98a3c15

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

articles/azure-app-configuration/feature-management-javascript-reference.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,35 @@ const featureProvider = new ConfigurationMapFeatureFlagProvider(appConfig);
130130
const featureManager = new FeatureManager(featureProvider);
131131
```
132132

133+
#### Use Azure App Configuration to dynamically control the state of the feature flag
134+
135+
Azure App Configuration is not only a solution to externalize storage and centralized management of your feature flags, but also it allows to dynamically turn on/off the feature flags.
136+
137+
To enable the dynamic refresh for feature flags, you need to configure the `refresh` property of `featureFlagOptions` when loading feature flags from Azure App Configuration.
138+
139+
``` typescript
140+
const appConfig = await load("YOUR_APP-CONFIG-ENDPOINT", new DefaultAzureCredential(), {
141+
featureFlagOptions: {
142+
enabled: true,
143+
refresh: {
144+
enabled: true, // enable the dynamic refresh for feature flags
145+
refreshIntervalInMs: 30_000
146+
}
147+
}
148+
});
149+
150+
const featureProvider = new ConfigurationMapFeatureFlagProvider(appConfig);
151+
const featureManager = new FeatureManager(featureProvider);
152+
```
153+
154+
You need to call the `refresh` method to get the latest feature flag state.
155+
156+
```typescript
157+
await appConfig.refresh(); // Refresh to get the latest feature flag settings
158+
const isBetaEnabled = await fm.isEnabled("Beta");
159+
console.log(`Beta is enabled: ${isBetaEnabled}`);
160+
```
161+
133162
> [!NOTE]
134163
> For more information about how to use feature management library with Azure App Configuration, please go to the [quickstart](./quickstart-javascript.md).
135164

0 commit comments

Comments
 (0)