Ale*_*sky 3 azure node.js azure-functions
在本地使用JavaScript开发Azure函数时,如何使用azure-functions-core-tools 在本地运行函数时获取/设置Node环境变量func host start --debug?
JavaScript中的Azure功能文档演示了目标功能应用程序设置process.env[settingName].当发布/部署从azure功能应用程序的应用程序设置中提取值时,这似乎很有效.
尝试在使用$env:FOO="bar"(powershell)或set FOO=bar命令提示符设置的函数内记录本地节点环境变量(Windows)时,它会记录未定义.尝试使用命令记录这些值context.log(process.env['FOO']).
index.js
const foo = process.env["FOO"];
module.exports = function (context, req) {
context.log('bar') // successfully logs 'bar' in the azure function log
context.log(foo); // logs undefined
if (req.query.name || (req.body && req.body.name)) {
context.res = {
// status: 200, /* Defaults to 200 */
body: "Hello " + (req.query.name || req.body.name)
};
} else {
context.res = {
status: 400,
body: "Please pass a name on the query string or in the request body"
};
}
context.done();
};
Run Code Online (Sandbox Code Playgroud)
感谢您提供任何帮助!
您是否local.settings.json在功能应用程序的根目录中使用文件?
{
"IsEncrypted": false,
"Values": {
"FOO": "-- Your Value --",
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1203 次 |
| 最近记录: |