【发布时间】:2015-05-15 14:57:19
【问题描述】:
我正在 Azure 中运行 Node.js 应用程序,并尝试获取如下配置设置:
var azure = require('azure');
azure.RoleEnvironment.getConfigurationSettings(function(error, settings) {
if (error) {
console.log(error);
return;
}
console.log('Settings: %s', settings);
});
但输出总是这样:
{ "code": "ENOENT", "errno": "ENOENT", "syscall": "connect", "fileName": "\\\\.\\pipe\\WindowsAzureRuntime" }
我正在使用 IISNode 使用所有最新位在 IIS 中运行 Node.Js。如果我在 Azure VM(即 node.exe server.js)上手动运行节点,我也会遇到同样的错误。在我的 PC 上运行 Azure Development Fabric 时也是如此。
提前感谢您的任何帮助或建议!
【问题讨论】:
-
找到了一个可行的解决方案,用于获取在 IISNode 中运行的 Node.Js 的 ServiceConfiguration.cscfg 设置值。例如,要使名为“TestSetting”的设置作为 IISNode 中的环境变量可供 Node 访问,必须将以下内容添加到 ServiceDefintion.csdef:
<Runtime> <Environment> <Variable name="TestSetting"> <RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/ConfigurationSettings/ConfigurationSetting[@name='TestSetting']/@value" /> </Variable> </Environment> </Runtime>
标签: javascript node.js azure