Azure Web App unexpected "Bad Request" - node.js

I'm occasionally getting "Bad Request" in the Azure Console (located in the main 'blade' of the Azure web app). One example is when running npm install grunt-sass but there were several other times with different commands, all of which are valid commands that should execute immediately with no errors.
I think this is a bug in Azure. I haven't seen the problem when using the Kudu Diagnostic Console.
Why is this happening?

On my side, it looks like depends on the npm version in the Azure Web Apps sanbox. I upgrade the npm version to 4.2.0, and successfully installed grunt-sass both via Kudu Conosole, or App Service Editor's Console Tool.
Please navigate to Application settings blade of your Azure Web Apps, and add the WEBSITE_NPM_DEFAULT_VERSION configuration in App settings section:
Then, it should work as expected.
In Kudu Console:
In App Service Editor:
At last, we recommend you can leverage custom deployment of Azure Web Apps, you can configure your dependencies in package.json, and deploy to Azure via Git, the deployment task will install the dependencies automatically, you can refer to Custom startup command for Node.js app on Azure with Babel 6 for the similar steps.

I found that if you're having a "Bad Request" error while running the npm install command in Azure App Service's Console, the npm process is still running in the background and it will complete.
That means that you should not try to run npm i again until it completes. You can monitor the progress via FTP - when the .staging folder in node_modules is empty, that means installation is complete.

Related

Azure App Service not installing all node dependencies

I have a nodejs azure app service. It seems like npm isn't installing all the dependencies correctly. The site runs locally fine, when i try in azure, I get 500 responses.
When I check the log, it shows various node dependencies missing. After I install the missing one using the console on the portal, another missing dependency notification pops up.
Using git deploy, I've tried just committing the entire node_modules folder, but for some reason, all the bits don't get uploaded.
Grateful for any ideas about how to sort this out.

Using WebDeploy with an Azure node website doesn't trigger npm install

I am using WebDeploy to deploy a node website to azure.
I've seen in samples and demos that it should trigger a npm install on deploy.
But it is not. I've also seen almost every demo uses git deployment.
Is automatic npm install not supported for WebDeploy or am I missing something?
when you use WebDeploy, it will just copy over all the file from your machine to cloud, it will not trigger any build process. You will have to responsible to make sure your app is ready to run.
if you want CI function, please setup continues deployment, here is tutorial for setting up local git
https://azure.microsoft.com/en-us/documentation/articles/web-sites-publish-source-control/
and there are other options if you have repository in github/bitbucket/Visual studio Team Service etc ... (go to https://portal.azure.com, select your site --> all settings --> continuous deployment to see all supported optinos)
According to the doc Publish to Microsoft Azure Website using Web Deploy, it said
Deployment will include all the files in your project. Files in the node_modules folder are included automatically, even if they are not part of the project.
So all files under your project folder in VS, including the node_modules folder, will be deployed.

Run NodeJS command on Azure

I am fairly new to NodeJS development. I have no issues whatsoever running commands on my local machine. For instance, say I want to install a package called "formidable" on my Node server, I'd run the command 'npm install formidable'. If I have deployed my NodeJS application to Azure, how would I run the same command?
NB - I do not want to manually run the command on my local machine and then deploy to Azure. This will take far too long, since I have to install many packages each with many files in them.
Please advise on how I go about doing this?
Thanks
Beside login KUDU console site and run command in online cmdlet. You also can configure dependencies in package.json, then you deploy your nodejs application to Azure via GIT, it will automatically install the dependencies in this file.
For example:
You add the formidable module in dependencies:
Then deploy it application on Azure Web Apps, you can see the remoting deployment logs in cmdlet that the module was added in the application on Azure, e.g.:
You can refer to Create a Node.js web app in Azure App Service for how to create a nodejs application and deploy via GIT.
If you are running an Azure Web App you can use Kudu Services.
To do this
browse to http://yoursitename.scm.azurewebsites.net
It will ask you to authenticate if you have not already
Click on Debug Console -> CMD
You can run your npm commands from there.
Screen shot below
More information can be found here: https://github.com/projectkudu/kudu/wiki

How can I debug deploy.sh when using Kudu to deploy a node.js app to Azure?

I am trying to deploy a node.js application (just a simple ghost blog) to Azure Websites using Kudu. I have the following lines in my deployment script (deploy.sh, which is referenced correctly from .deployment):
eval $NPM_CMD install grunt-cli
exitWithMessageOnError "Problem Installing Grunt"
./node_modules/.bin/grunt --no-color init
exitWithMessageOnError "Problem With Grunt"
When the deployment fails, I look into the Azure Management Portal and see the log of the failure. I get the expected output when npm install grunt-cli is run - i.e. a warning that it should be installed globally and a list of subpackages indicating that it has installed correctly anyway. Then, directly afterwards I get:
An error has occurred during web site deployment.
Problem With Grunt
The same sequence (with no further information) is in the log.xml for the deployment available from the Kudu deployment dump.
How should I tackle this? Are there any other places I can look for output and errors? Can I change my script to output more error information? Where will it go if I do? Is there some way of testing my deployment script using the Kudu remote console utility?

Deploy sails.js to Windows Azure Website

I'm following this guide on installing a node.js application on Azure:
http://www.windowsazure.com/en-us/develop/nodejs/tutorials/create-a-website-(mac)/#header-0
Is it possible to get a sails.js app running without having to instantiate a Virtual Machine?
New guide on deploying to Windows Azure:
https://github.com/mdrmuhaimin/sails-docs/blob/b1030c21daf885e6490e1d1f946375a5c8584e4c/Guide:Deploying-Sails-to-windows-azure-linux-vm.md
Also, as I mentioned in the comment above, you don't have to install Sails globally to deploy it-- just clone your app, run npm install, and then forever start app.js or node app.js. See the deployment guide for more info.
As of right now sails requires an npm install -g on the box which would require either a virtual machine or a cloud service with a startup script. The link you are showing if for a deployment model where you don't get any access to manipulate the host since there are many instances running on it.
It would be great if sails could be included inside an app by putting it in the package.json and started up from within the app.
UPDATE - This has changed since the answer was posted. #mikermcneil has an updated answer that reflects the current state.

Resources