Last active
April 17, 2023 11:46
-
-
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
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
// 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