Skip to content

Commit 26ff70f

Browse files
add example
1 parent 486ef1b commit 26ff70f

File tree

6 files changed

+915
-7
lines changed

6 files changed

+915
-7
lines changed

examples/console-app/.env.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ APPCONFIG_ENDPOINT=<app-configuration-endpoint>
1010
AZURE_TENANT_ID=<AD tenant id or name>
1111
AZURE_CLIENT_ID=<ID of the user/service principal to authenticate as>
1212
AZURE_CLIENT_SECRET=<client secret used to authenticate to Azure AD>
13+
14+
AZURE_FRONT_DOOR_ENDPOINT=<Azure Front Door endpoint>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
import * as dotenv from "dotenv";
5+
import { promisify } from "util";
6+
dotenv.config();
7+
const sleepInMs = promisify(setTimeout);
8+
9+
/**
10+
* This example retrives all settings with key following pattern "app.settings.*", i.e. starting with "app.settings.".
11+
* With the option `trimKeyPrefixes`, it trims the prefix "app.settings." from keys for simplicity.
12+
* Value of config "app.settings.message" will be printed.
13+
*
14+
* Below environment variables are required for this example:
15+
* - APPCONFIG_CONNECTION_STRING
16+
*/
17+
18+
import { loadFromAzureFrontDoor } from "@azure/app-configuration-provider";
19+
const endpoint = process.env.AZURE_FRONT_DOOR_ENDPOINT;
20+
const settings = await loadFromAzureFrontDoor(endpoint, {
21+
selectors: [{
22+
keyFilter: "CDN.*"
23+
}],
24+
trimKeyPrefixes: ["CDN."],
25+
refreshOptions: {
26+
enabled: true,
27+
refreshIntervalInMs: 15_000
28+
}
29+
});
30+
31+
while (true) {
32+
await settings.refresh();
33+
console.log(`Message from Azure Front Door: ${settings.get("Message")}`);
34+
// wait for 30 seconds
35+
await sleepInMs(30_000);
36+
}

examples/console-app/helloworld.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the MIT license.
33

44
import * as dotenv from "dotenv";
5-
dotenv.config()
5+
dotenv.config();
66

77
/**
88
* This example retrives all settings with key following pattern "app.settings.*", i.e. starting with "app.settings.".

examples/console-app/helloworld_aad.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the MIT license.
33

44
import * as dotenv from "dotenv";
5-
dotenv.config()
5+
dotenv.config();
66

77
/**
88
* This example retrives all settings with key following pattern "app.settings.*", i.e. starting with "app.settings.".

0 commit comments

Comments
 (0)