realisation realisation - 17 days ago 8
Node.js Question

AZURE Web Apps: deploying Angular SPA & Node Express server from Github repository

I have a webapp in a Github repository that has an Angular client and a Node Express backend server. I have no idea how to deploy these simultaneously to an Azure webapp. None of the tutorials cover this. The only thing they tell you to do is to have an index.html or a server.js in a root directory, which isn't how my app is structured.

But I did try moving the server to a server.js in the root directory, and then nothing happened there.

I have no idea where to start with this. Thank you very much for any help.

Tell me what more information you need because I have no idea and there is zero documentation for this.

Update: None of this appears to be working. I tried switching the virtual path for

/
to the dist folder where
index.html
lives, but this didn't do anything.

Answer

As it seems you also open a thread on MSDN with this issue at https://social.msdn.microsoft.com/Forums/azure/en-US/a6cbc494-dc42-4962-99c7-947cee7ff25a/nodejs-deploying-angular-spa-application-node-server-through-github-continuous-integration?forum=windowsazurewebsitespreview.

Node.js application on Azure should have an app.js or a server.js in the root of the application.

So Here is a workaround, if you want your angular app in dist folder acts as the frontend of your web application and the expressjs application acts as the backend service.

You can deploy the express js application in the root directory and the angular app folder in the same root directory too. Then you can configure the angular app in the exrepssjs routes. E.G

assume your angular app entrance is index.html in dist folder in root directory:

app.get('/', function(req, res) {
    res.sendfile(__dirname+'/dist/index.html')

}); 

Which will route "/" to your angular app.

Comments