Skip to content

Commit c5754b2

Browse files
update
1 parent 855384d commit c5754b2

File tree

3 files changed

+27
-34
lines changed

3 files changed

+27
-34
lines changed

articles/azure-app-configuration/howto-targetingfilter-javascript.md

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ In this section, you create a web application that uses the *Beta* feature flag
5252
5353
let appConfig;
5454
let featureManager;
55+
5556
async function initializeConfig() {
5657
appConfig = await load(appConfigEndpoint, new DefaultAzureCredential(), {
5758
featureFlagOptions: {
@@ -62,8 +63,18 @@ In this section, you create a web application that uses the *Beta* feature flag
6263
}
6364
});
6465
65-
const featureFlagProvider = new ConfigurationMapFeatureFlagProvider(appConfig);
66-
featureManager = new FeatureManager(featureFlagProvider);
66+
featureManager = new FeatureManager(new ConfigurationMapFeatureFlagProvider(appConfig));
67+
}
68+
69+
function buildContent(title, message) {
70+
return `
71+
<html>
72+
<head><title>${title}</title></head>
73+
<body style="display: flex; justify-content: center; align-items: center;">
74+
<h1 style="text-align: center; font-size: 5.0rem">${message}</h1>
75+
</body>
76+
</html>
77+
`;
6778
}
6879
6980
function startServer() {
@@ -75,26 +86,12 @@ In this section, you create a web application that uses the *Beta* feature flag
7586
7687
app.get("/", async (req, res) => {
7788
const { userId, groups } = req.query;
78-
const beta = await featureManager.isEnabled("Beta", { userId: userId, groups: groups ? groups.split(",") : [] });
79-
if (beta) {
80-
res.send(`
81-
<html>
82-
<head><title>Beta Page</title></head>
83-
<body style="display: flex; justify-content: center; align-items: center;">
84-
<h1 style="text-align: center; font-size: 5.0rem">This is a beta page.</h1>
85-
</body>
86-
</html>
87-
`);
88-
} else {
89-
res.send(`
90-
<html>
91-
<head><title>Home Page</title></head>
92-
<body style="display: flex; justify-content: center; align-items: center;">
93-
<h1 style="text-align: center; font-size: 5.0rem">Welcome.</h1>
94-
</body>
95-
</html>
96-
`);
97-
}
89+
const isBetaEnabled = await featureManager.isEnabled("Beta", { userId: userId, groups: groups ? groups.split(",") : [] });
90+
91+
res.send(isBetaEnabled ?
92+
buildContent("Beta Page", "This is a beta page.") :
93+
buildContent("Home Page", "Welcome.")
94+
);
9895
});
9996
10097
const port = "8080";

articles/azure-app-configuration/howto-variant-feature-flags-javascript.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ In this tutorial, you use a variant feature flag to manage experiences for diffe
5151
5252
let appConfig;
5353
let featureManager;
54+
5455
async function initializeConfig() {
5556
appConfig = await load(appConfigEndpoint, new DefaultAzureCredential(), {
5657
featureFlagOptions: {
@@ -61,8 +62,7 @@ In this tutorial, you use a variant feature flag to manage experiences for diffe
6162
}
6263
});
6364
64-
const featureFlagProvider = new ConfigurationMapFeatureFlagProvider(appConfig);
65-
featureManager = new FeatureManager(featureFlagProvider);
65+
featureManager = new FeatureManager(new ConfigurationMapFeatureFlagProvider(appConfig));
6666
}
6767
6868
function startServer() {

articles/azure-app-configuration/quickstart-feature-flag-javascript.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Add a feature flag called *Beta* to the App Configuration store and leave **Labe
5555

5656
async function run() {
5757
// Connect to Azure App Configuration using endpoint and token credential
58-
const settings = await load(endpoint, credential, {
58+
const appConfig = await load(endpoint, credential, {
5959
featureFlagOptions: {
6060
enabled: true,
6161
// Note: selectors must be explicitly provided for feature flags.
@@ -69,13 +69,11 @@ Add a feature flag called *Beta* to the App Configuration store and leave **Labe
6969
}
7070
});
7171

72-
// Create a feature flag provider which uses a map as feature flag source
73-
const ffProvider = new ConfigurationMapFeatureFlagProvider(settings);
7472
// Create a feature manager which will evaluate the feature flag
75-
const fm = new FeatureManager(ffProvider);
73+
const fm = new FeatureManager(new ConfigurationMapFeatureFlagProvider(appConfig));
7674

7775
while (true) {
78-
await settings.refresh(); // Refresh to get the latest feature flag settings
76+
await appConfig.refresh(); // Refresh to get the latest feature flag settings
7977
const isEnabled = await fm.isEnabled("Beta"); // Evaluate the feature flag
8078
console.log(`Beta is enabled: ${isEnabled}`);
8179
await sleepInMs(5000);
@@ -94,7 +92,7 @@ Add a feature flag called *Beta* to the App Configuration store and leave **Labe
9492

9593
async function run() {
9694
// Connect to Azure App Configuration using connection string
97-
const settings = await load(connectionString, {
95+
const appConfig = await load(connectionString, {
9896
featureFlagOptions: {
9997
enabled: true,
10098
// Note: selectors must be explicitly provided for feature flags.
@@ -108,13 +106,11 @@ Add a feature flag called *Beta* to the App Configuration store and leave **Labe
108106
}
109107
});
110108

111-
// Create a feature flag provider which uses a map as feature flag source
112-
const ffProvider = new ConfigurationMapFeatureFlagProvider(settings);
113109
// Create a feature manager which will evaluate the feature flag
114-
const fm = new FeatureManager(ffProvider);
110+
const fm = new FeatureManager(new ConfigurationMapFeatureFlagProvider(appConfig));
115111

116112
while (true) {
117-
await settings.refresh(); // Refresh to get the latest feature flag settings
113+
await appConfig.refresh(); // Refresh to get the latest feature flag settings
118114
const isEnabled = await fm.isEnabled("Beta"); // Evaluate the feature flag
119115
console.log(`Beta is enabled: ${isEnabled}`);
120116
await sleepInMs(5000);

0 commit comments

Comments
 (0)