Get Started in Less Than 5 Minutes
This quickstart guides you through deploying a simple Node.js web app to Azure App Service using the Azure CLI.
- Install the Azure CLI and log in:
az login
- Create a resource group:
az group create --name quickstart-rg --location eastus
- Create an App Service plan:
az appservice plan create --name quickstart-plan --resource-group quickstart-rg --sku B1 --is-linux
- Create a web app:
az webapp create --resource-group quickstart-rg --plan quickstart-plan --name <unique-app-name> --runtime "NODE|14-lts"
- Deploy sample code:
git clone https://github.com/Azure-Samples/nodejs-docs-hello-world cd nodejs-docs-hello-world az webapp deployment source config-local-git --name <unique-app-name> --resource-group quickstart-rg git remote add azure $(az webapp deployment source show --name <unique-app-name> --resource-group quickstart-rg --query url -o tsv) git push azure main
- Browse to
https://<unique-app-name>.azurewebsites.net
and see your running app.
Sample Code
Below is the server.js
used in the sample application.
const express = require('express');
const app = express();
const port = process.env.PORT || 3000;
app.get('/', (req, res) => {
res.send('Hello from Azure App Service!');
});
app.listen(port, () => {
console.log(`App listening on port ${port}`);
});