Last active
December 30, 2022 17:49
-
-
Save manoj-choudhari-git/5a4f0b92cdabba67f897f617375cd035 to your computer and use it in GitHub Desktop.
JavaScript - Azure App Configuration Service - Read key-value pairs from JavaScript code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ------------------------------------------------------------------ | |
// To Make a new directory | |
// md javascript-demo | |
// ------------------------------------------------------------------ | |
// Create a new file: javascript-demo.js | |
// contents of that file are: | |
async function run() { | |
let retrievedSetting = await client.getConfigurationSetting({ | |
key: "TestApi:PostEndpoint:Message" | |
}); | |
console.log("Retrieved value:", retrievedSetting.value); | |
} | |
const appConfig = require("@azure/app-configuration"); | |
// Read Connection String From Environment Variable | |
const connection_string = process.env.AZURE_APP_CONFIG_CONNECTION_STRING; | |
// Prepare the client | |
const client = new appConfig.AppConfigurationClient(connection_string); | |
// Call the method which fetches the data | |
run().catch((err) => console.log("ERROR:", err)); | |
// ------------------------------------------------------------------ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment