Skip to content

Instantly share code, notes, and snippets.

@DhyanRathore
Last active April 17, 2023 11:46
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 DhyanRathore/45b849955ccc21da797b8d0ef0c5022c to your computer and use it in GitHub Desktop.
Save DhyanRathore/45b849955ccc21da797b8d0ef0c5022c to your computer and use it in GitHub Desktop.
Azure Function: Node.js code to read Environment Variables during function execution and return variables as JSON
// Azure Function: Node.js code to read Environment Variables during function execution and return variables as JSON
// Author: Dhyanendra Singh Rathore
// Entry point of the function
module.exports = async function(context, req) {
// Fetch environment variables during execution
const postgresServerName = process.env["POSTGRES_SERVER_NAME"];
const postgresUserName = process.env["POSTGRES_USER"];
// Create JSON response with the variables
const responseMessage = {
"Server FQDN": postgresServerName,
"User Name": postgresUserName
};
// Return the response
context.res = {
status: 200,
isRaw: true,
body: responseMessage,
headers: {
'Content-Type': 'application/json'
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment