Hot questions for Using Azure in javascript

Top Java Programmings / Azure / javascript

Question:

I make a node js web app for generating report. My idea is to use .jasper file (jasper report) to generate these reports. I've tried a bunch of node js library to do this, but nothing seems to work. And finally I proceed to make a .jar file (java) to solve this. The process is as follows:

  1. Node js get request from user
  2. Node js run .jar file by using child_process. It run something like "java -jar MyApp.jar arg1 arg2 arg3"
  3. .jar file generate a pdf and save it to a folder
  4. .jar file return the path of newly generated pdf file
  5. Node js get the path and return pdf file to user

It run perfectly in my computer. Then I upload it to Microsoft Azure. It seems like the run .jar file step is failed, because no pdf file is created. Can anyone help me or suggest a better way to do this?


Answer:

If you deployed the NodeJS webapp into MS Azure WebApps, the step 2 of the process could not spawn a child process for running a jar runnable file because the Java runtime environment not included your current Azure WebApp with NodeJS.

There are three suggested way to do this:

  1. Using Azure VM to install NodeJS and Java, and deploy your app on the VM as the same as on the local computer. It's the simple way.

  2. I searched an open source report software called jsreport. It can be install on MS Azure VM or Cloud Service. You can refer to the download page Run jar file with node js on Microsoft Azure to install it. And there is the jsreport sdk for NodeJS http://jsreport.net/learn/nodejs. If you want to use jsreport on Azure Cloud Service, you need to know how to build NodeJS App on Azure Cloud Service https://azure.microsoft.com/en-us/documentation/articles/cloud-services-nodejs-develop-deploy-express-app/.

  3. Changing your process. NodeJS get request from user and send it with the specified file name and path to the ServiceBus; The jar runnable file modified as a Azure WebJob read the request from the ServiceBus and generate a pdf with the given file name and save it to the given file path on the Azure Blob Storage; NodeJS directly return pdf file to user from Blob Storage.

For Azure WebJob & Service Bus, you can refer to https://azure.microsoft.com/en-us/documentation/articles/web-sites-create-web-jobs/ and https://azure.microsoft.com/en-us/documentation/articles/service-bus-nodejs-how-to-use-queues/.

Question:

Iam a beginner in Microsoft event hub. I am successfully reading sample string data from eventHub using node js consumer. but i need to consume octet-stream data. this is my code

var messageHandler = function (myIdx, msg) {
console.log("############# Inside Message Handler #######");
console.log(msg.body);
}

i dont get the correct data. But am successfully read data from a txt file. this is my code

fs.readFile('/home/test/19_6.txt',  function (err, data) {
console.log(data);
}

what i do? any idea ????

this is my octet-stream data Click here to view


Answer:

Per my experience, you can read a file as byte array and use Base64 encoding to convert it to a string, and then send the Base64 string to EventHub. When you receive the data, you can decode the Base64 string to a byte array.

But I don't recommend this way, because of some limits in EventHub.

Firstly, Maximum size of Event Hubs event is 256KB. Message that exceed this quota will be rejected and an exception will be received by the calling code. Please refer to https://azure.microsoft.com/en-us/documentation/articles/service-bus-quotas/.

Secondly, you need to use some C# APIs such as Event Processor Host API to receive messages from Event Hubs. Please refer to https://azure.microsoft.com/en-us/documentation/articles/event-hubs-programming-guide/#event-consumers. If you want to use NodeJS to do it, it will be difficult though Event Hub/Service Bus support AMQP protocol.

So I think that you would like to know how to send files to a queue and receive them to do some process. I recommend you to use Azure Storage Queue to implement your idea.

About use Storage Queue from NodeJS, please refer to https://azure.microsoft.com/en-us/documentation/articles/storage-nodejs-how-to-use-queues/ and http://azure.github.io/azure-storage-node/#toc7.

Question:

Is there a reason why my web app inside an Azure web app is returning a 404 error saying:

Failed to load resource: the server responded with a status of 404 ()

The path for the file is: https://WEB-APP-NAME-HERE.azurewebsites.net/resources/demos/style.css

If I look into my project files and folders, I do not have a recources folder, nor a demos folder and for sure no style.css file.

Can this message be turned of inside portal.azure.net? Or can this path be deleted so that Azure / the web app doesn't check it anymore?

Thanks in advance.


Answer:

Have you searched your actual code for a reference to that file?

Or would it previously have been there and a bot is trying to re-read it?