The key of successfull deployment is use the boilerplate. The web.config provided enables the application the use different routes.
Fork it on https://github.com/Azure-Samples/nodejs-docs-hello-world.
npm install express
var express = require('express');
var app = express();
var port=process.env.PORT || 3000;
app.use(express.static(__dirname + '/public'));
app.get('/', function (req, res) {
res.send('Hello World');
})
app.get('/teste', function (req, res) {
res.send('Hello World Teste');
})
app.listen(port);
console.log('Server Listening at port '+port);
npm start
Check the URL and test the routes. If everything is fine, it's time to deploy to Azure Web App. Here, https://docs.microsoft.com/pt-br/azure/app-service/app-service-web-get-started-nodejs, are the detailed commands to create the Web App.
Let's summarize:
az group create --name myResourceGroup --location "West Europe"
az appservice plan create --name myAppServicePlan --resource-group myResourceGroup --sku FREE
az webapp create --resource-group myResourceGroup --plan myAppServicePlan --name <app_name> --runtime "NODE|6.9"
Zip all files of project, including the "node_modules", then use the Kudu, Zip Deployment,https://<app_name>.scm.azurewebsites.net/ZipDeploy
, and drag the Zip file.
Check the routes, the root and "teste".