When I built my first Express API, running it on localhost:5000 felt great until I wanted to share it with someone else. Sending local endpoints to teammates or setting up temporary tunnels like ngrok gets annoying fast.
If you build backends with Node.js and Express, pushing your API to the cloud is a fundamental skill. In this guide, we will take a simple Express API and deploy it to Azure App Service so you have a live, HTTPS-enabled production URL.
Prerequisites
Before diving into the setup, make sure you have the following ready:
- Node.js installed on your local machine.
- An active Azure Account. If you don't have one, grab the Azure for Students plan which gives you free credits without needing a credit card:
https://azure.microsoft.com/free/students/?wt.mc_id=studentamb_512515
- Visual Studio Code with the Azure App Service extension installed. You can download the editor directly from VS Code Docs:
https://code.visualstudio.com/docs?wt.mc_id=studentamb_512515
Step 1: Set Up Your Express Server
If you already have a Node.js project, you can skip to Step 2. Otherwise, let's create a minimal Express server.
Initialize a new directory and install Express:
Bash
mkdir express-azure-demo
cd express-azure-demo
npm init -y
npm install express dotenv
Create a file named server.js in the root folder:
JavaScript
const express = require('express');
const app = express();
// Azure dynamically assigns a PORT environment variable
const PORT = process.env.PORT || 5000;
app.use(express.json());
app.get('/', (req, res) => {
res.json({
message: 'Express API is running smoothly on Azure App Service!',
status: 'Success',
timestamp: new Date()
});
});
app.get('/api/health', (req, res) => {
res.status(200).json({ status: 'UP' });
});
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
Important Rule for Azure: package.json
Azure needs to know how to start your application once it deploys the code. Open your package.json and ensure your scripts section includes a start command:
JSON
"scripts": {
"start": "node server.js"
}
Step 2: Create the App Service Resource
There are multiple ways to deploy—using the Azure CLI, Git integration, or VS Code. Using VS Code is the straightest path for a quick deployment:
- Open your project folder in Visual Studio Code.
- Click on the Azure icon in the left sidebar.
- Sign in to your Azure account if prompted.
- Under the App Service section, click the + (Plus) button to create a new Web App.
- Enter a unique name for your API (e.g., my-express-api-2026).
- Select your runtime stack: Node.js (LTS version).
- Select the Free (F1) pricing tier for testing. Azure will spend about a minute provisioning your server environment.
Step 3: Deploy the Code
Once the resource creation finishes, deploying your code takes just a few clicks:
- In VS Code, open the Command Palette (Ctrl+Shift+P on Windows/Linux or Cmd+Shift+P on macOS).
- Type and select Azure App Service: Deploy to Web App...
- Select your project folder (express-azure-demo).
- Select the Web App resource you created in Step 2.
- A popup will ask if you want to overwrite previous deployments. Click Deploy. VS Code will package your files, upload them to Azure, run npm install inside the cloud environment, and execute npm start.
Step 4: Verify Your API Live
Once the deployment output window displays "Deployment successful," copy your app's public URL:
https://.azurewebsites.net
Open your browser or Postman and hit the URL. You should get back the JSON response:
JSON
{
"message": "Express API is running smoothly on Azure App Service!",
"status": "Success",
"timestamp": "2026-08-05T16:35:23.000Z"
}
Common Issues & Troubleshooting
• 502 Bad Gateway / Application Error: Check your port setup. Make sure your code relies on process.env.PORT instead of hardcoding 5000 or 3000. Azure handles internal routing dynamically using its own port mapping.
• Missing Dependencies: Ensure node_modules is listed in your .gitignore file so VS Code doesn't try to upload local modules. Let Azure run npm install on its own server.
📚 Helpful Resources & Documentation
• Official Azure App Service Documentation:
https://learn.microsoft.com/azure/app-service/?wt.mc_id=studentamb_512515
• Get Started with Azure Free for Students:
https://azure.microsoft.com/free/students/?wt.mc_id=studentamb_512515
• Visual Studio Code Node.js Tutorial Guide:
https://code.visualstudio.com/docs/nodejs/nodejs-tutorial?wt.mc_id=studentamb_512515
In the next episode, we'll look at how to take a React frontend, host it for free on Azure Static Web Apps, and connect it directly to this Express backend.
Top comments (1)
Some comments may only be visible to logged-in visitors. Sign in to view all comments.