How to set Azure Function Environment Variable for development and production-ready code?
ExpressJS already provided Environment config file, how to set Azure Function Environment Variable?
How to set Azure Function Environment Variable for development and production-ready code?
ExpressJS already provided Environment config file, how to set Azure Function Environment Variable?
For development you can add variables in local.settings.json :
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "node",
"host": "localhost",
}
}
And use it with :
process.env["host"]
For production you can add a Configuration of the Application in :
And this will override the variables in local.settings.json
Azure Functions provide us with a local.settings.json
file where we can define these variables.
{
"IsEncrypted": false,
"Values": {
"FOO": "-- Your Value --",
}
}
You can access it from your code using process.env["FOO"]
Refer official docs
If you want the settings post deployment, when you publish the function use the --publish-local-settings -i
switch during publishing.
© 2022 - 2024 — McMap. All rights reserved.