3

I am using this piece of code to call the service bus queue from my node.js file running in Azure Worker Role .

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");

In this code worker role only log "start" and "end" but getQueue API is not working and not throwing any error and it is working fine on my local machine and logging the response.

1 Answers1

0

I tested in a new Cloud Service with your node.js script code, and deploy to Azure. And I configed the .csdef file to pipe the output into a log file, like: <ProgramEntryPoint commandLine="node.cmd .\worker.js &gt; sblog.txt" setReadyOnProcessStart="true" /> to check the output of the node.js script.

Everything worked fine on my side. Could you please confirm whether you have messages in your queue, and whether you have any specific configurations in your .csdef file.

update

According the description at 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.

And we can check the available nodejs version in cloud service via the powershell command: Get-AzureServiceProjectRoleRuntime. The available version list is :0.6.17,0.6.20,0.8.4,0.8.22,0.8.26 and 0.10.21.

If you want to use your custom nodejs version, you can package the entire node.js execute application folder into your cloud service application. And modify the node.cmd file in your cloud service application to direct the node.js execute application's path in your cloud service package.

Community
  • 1
  • 1
Gary Liu
  • 13,758
  • 1
  • 17
  • 32
  • Yes messages are available in the queue and here is my .csdef file code – AvinashSachdewani Aug 12 '16 at 09:34
  • one more point I changed the node verion in package.json adding this line( "engines": {"node": "4.4.7", "iisnode": "*"} ) and also run this cmdlet (Set-AzureServiceProjectRole WebRole1 Node 4.4.7) before publishing the application but when I am running the command (node -v) in worker role it is showing 0.6.20 so which node js version applicale in application ? – AvinashSachdewani Aug 12 '16 at 09:49
  • 1
    Is the content your whole content in `.csdef`? Could you make it work to build a new cloud service leverage Visual Studio? – Gary Liu Aug 16 '16 at 06:58
  • Thanks Gary for the support It's working now I have changed the node JS version to (0.10.21) and also add a startup tag in csdef file. But the problem was no error message was coming so it's hard to track the problem. – AvinashSachdewani Aug 24 '16 at 14:08