Skip to content

Instantly share code, notes, and snippets.

@manoj-choudhari-git
Last active December 30, 2022 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manoj-choudhari-git/5a4f0b92cdabba67f897f617375cd035 to your computer and use it in GitHub Desktop.
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
// ------------------------------------------------------------------
// 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