File tree Expand file tree Collapse file tree 6 files changed +915
-7
lines changed Expand file tree Collapse file tree 6 files changed +915
-7
lines changed Original file line number Diff line number Diff line change @@ -10,3 +10,5 @@ APPCONFIG_ENDPOINT=<app-configuration-endpoint>
1010AZURE_TENANT_ID = <AD tenant id or name>
1111AZURE_CLIENT_ID = <ID of the user/service principal to authenticate as>
1212AZURE_CLIENT_SECRET = <client secret used to authenticate to Azure AD>
13+
14+ AZURE_FRONT_DOOR_ENDPOINT = <Azure Front Door endpoint>
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 22// Licensed under the MIT license.
33
44import * 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.".
Original file line number Diff line number Diff line change 22// Licensed under the MIT license.
33
44import * 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.".
You can’t perform that action at this time.
0 commit comments