gpt4 book ai didi

node.js - 适用于 Node JS 的 Azure SDK 无法在 Azure 辅助角色中工作

转载 作者:搜寻专家 更新时间:2023-11-01 00:06:07 24 4
gpt4 key购买 nike

我使用这段代码从在 Azure 辅助角色中运行的 node.js 文件调用服务总线队列。

var azure = require('azure'),
config = require('./config');
var serviceBusClient = azure.createServiceBusService(config.sbConnection);
console.log("Start");
serviceBusClient.getQueue("myqueue", function (error, queue) {
if(error){
console.log(error);
}
console.log(queue);
});
console.log("End");

在此代码中,辅助角色仅记录“开始”和“结束”,但 getQueue API 无法正常工作并且不会引发任何错误,并且它在我的本地计算机上正常工作并记录响应。

最佳答案

我使用您的 node.js 脚本代码在新的云服务中进行了测试,并部署到 Azure。我配置了 .csdef file 将输出通过管道传输到日志文件中,例如:<ProgramEntryPoint commandLine="node.cmd .\worker.js &gt; sblog.txt" setReadyOnProcessStart="true" />检查 Node.js 脚本的输出。

我这边一切正常。您能否确认您的队列中是否有消息,以及.csdef中是否有任何特定配置文件。

更新

根据https://azure.microsoft.com/en-us/documentation/articles/nodejs-specify-node-version-azure-apps/处的描述:

If you are hosting your application in an Azure Cloud Service (web or worker role,) and it is the first time you have deployed the application, Azure will attempt to use the same version of Node.js as you have installed on your development environment if it matches one of the default versions available on Azure.

我们可以通过powershell命令查看云服务中可用的nodejs版本:Get-AzureServiceProjectRoleRuntime 。可用版本列表为:0.6.17 , 0.6.20 , 0.8.4 , 0.8.22 , 0.8.260.10.21 .

如果您想使用自定义的nodejs版本,您可以将整个node.js执行应用程序文件夹打包到您的云服务应用程序中。并修改node.cmd在您的云服务应用程序中创建一个文件来引导node.js执行应用程序在您的云服务包中的路径。

关于node.js - 适用于 Node JS 的 Azure SDK 无法在 Azure 辅助角色中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38900397/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com