Azure Git Continuous Deploy for node not working - node.js

We have a REST API (npm restify) to deploy to Azure and it was successful.
After this we have the web.config pointing it to the app.js in the root (was server.js as stock). Looking at the logs it says pointing to 0.0.0.0 on port 8085. We are not sure how to change this as we have env variables set to change these but Azure kudu doesnt seem to listen.
The app.js is also just a module.exports = require(".src/server.js"); Any thoughts would be much appreciated!

Turns out it was the env variables. We had BLAH_BLAH_PORT when it should have been just PORT

Related

Heroku fails to host my Node.js App , I just see "Cannot Get /"

I have looked at similar questions and not been able to solve this problem with what I found. I initially followed a YouTube tutorial on how to deploy a Node.js App to Heroku. After trying and failing, I began troubleshooting and could not fix the problem.
I then followed the instructions on Heroku's website for deploying a Node.js application here: https://devcenter.heroku.com/articles/deploying-nodejs and I found I seem to have done all the steps correctly. I was just missing the node version in the package.json which I have now added.
Here is how I have connected my Node.js app:
image of Heroku application dashboard
And here is the connected Github repo: https://github.com/AmeenIzhac/food-and-flow-backend
You can see in the repo that my port is specified correctly:
const port = process.env.PORT || 4000;
I then tried running the app locally on the command line with:
heroku local web
and this worked as you can see my application running on port 5000:
App running locally on port 5000
However when I press "Open app" in Heroku, I just see this:
Heroku hosted app fails to get /
I feel like I have done everything correctly but it doesn't seem to work. Any help to get it working would be much appreciated.
You need a procfile. What is the heroku error in heroku logs --tail?

Why is my basic hello world nodejs app not working on Heroku?

I got this errror:
Application error
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command
heroku logs --tail
I tried adding various repositories that other people have built as well.
Does Heroku require certain file requirements for the app to show up?
My git repository is located here: https://github.com/nathanpuls/helloworld2
My heroku app is located here: https://wyresapp.herokuapp.com/
If you have deployed your app to Heroku as it is in the git repository, then you are missing two things.
You should assign an environment value for the port so that Heroku can use it to set the port number. It won't run the app on a user-defined port number. It should look sth like,
var port = process.env.port || 3000;
Procfile is missing. It is a simple file that instructs what kind of app you have and how it should start. In your case, it should be
web: node index.js

How to node js app move to production see on live api data

I tried to sucessfully bulid node js api using crud Operation and working fine in locally.but how to move production to live see the api data.I tried pm2 but also working for local ipaddress.how to solve this problem any solution..
Change the host name in server.js or index.js file from 'localhost' to 0.0.0.0 then you server will expose to the outside of the your network
Change 'localhost' to '0.0.0.0'
If you have any firewalls you must allow your server port to outside network.
If you are using pm2, you can select environment as production while starting the process.
pm2 start config.js --env production
Ref: http://pm2.keymetrics.io/docs/usage/environment/

Node js deployement in Azure server could not be accesses outside using ip

I tried deploying a simple node js service in azure ubuntu using CLI,console logs says the server is up on port 8080(this same service works perfectly in my local machine),but when i tried to access the public ip from outside,it gives site can't be reached
Following was the output when i deployed my service
azureuser#myVM:~/drugdemo/user_service/drulistService$ vi server.js
azureuser#myVM:~/drugdemo/user_service/drulistService$ node server.js
App is listening on 8080
^C^C
azureuser#myVM:~/drugdemo/user_service/drulistService$ pm2 start server.js
[PM2] Starting
/home/azureuser/drugdemo/user_service/drulistService/server.js in fork_mode (1 instance)
[PM2] Done.
Use `pm2 show <id|name>` to get more details about an app
azureuser#myVM:~/drugdemo/user_service/drulistService$
Please help me with your suggections.
(I already tried changing 'localhost' to '0.0.0.0' and '127.0.0.1' but didn't work for me)
Thank you in advance
Make sure to open the firewall port via Azure as well and not just the server.
This may help: https://blogs.msdn.microsoft.com/pkirchner/2016/02/02/allow-incoming-web-traffic-to-web-server-in-azure-vm/

PeerJS Server 404 on Azure

I'm trying to deploy a PeerJS server on Azure. On my kudu console, running
node peerjs --port 9000
returns
Started PeerServer on ::, port: 9000, path: / (v. 0.2.8)
However, when I try to connect to the server from my client code, I get a 404. Going directly to appname.azurewebsites.net/peerjs/id in my browser also returns a 404.
I see inside their package.json file, they run
bin/peerjs --port ${PORT:=9000}
instead of just passing in 9000 directly; I assume this is an environment variable. However, trying to run this on Azure gives
Error: Error: listen EACCES ${PORT:=9000}
which I assume means Azure doesn't recognize ${PORT:=9000} as a valid port.
I know for a fact there's nothing wrong with my client side code because a) I copied it directly from PeerJS's website, and b) everything works correctly when I deployed PeerJS to Heroku. It's only not running on Azure.
Other things I've tried: I edited peerjs in the bin folder to use process.env.PORT instead of what's passed in via the command line, but that didn't work, giving the same EACCES error. When I tried to console.log(process.env.PORT), I got undefined. None of my Google searches have turned up any solutions, although this person (Custom PeerJs Server giving ERR_CONNECTION_TIMED_OUT) seems to have a similar error, not on Azure.
Azure App Service doesn't allow us to listen on a customer port. We need to use process.env.PORT instead. See Listen additional port Microsoft Azure Nodejs.
Azure App Service (on Windows platform) runs on Microsoft IIS. So we need to put the app files to its virtual directory (D:\home\site\wwwroot) and no longer need to manually run the app via the Kudu console.
In this case, you first need to install the library under app's root:
npm install peer
And then create a file named index.js or app.js with following content and put it to /wwwroot folder:
var PeerServer = require('peer').PeerServer;
var server = PeerServer({port: process.env.PORT, path: '/'});
As #Mikkel mentioned in a comment, PeerServer uses WebSocket protocol, so Web Sockets should be enabled in the Azure portal like this:
You also need to check out this post to add a web.config file for your app if it has not been created yet.
This will be a firewall problem... You will need to open port 9000 in your Azure settings panel.
From the machine itself, open up a browser to http://localhost:9000/ or http://localhost:9000/peerjs and you should see the standard Peerjs server JSON output.
Or if you only have command line, try curl http://localhost:9000/ or http://localhost:9000/peerjs

Resources