1️⃣ What is Azure App Service?¶
Azure App Service is a PaaS (Platform as a Service) to host:
-
Web apps
-
REST APIs
-
Backend services
-
Frontend apps (SPA)
-
Containers
👉 No server management (OS, patching, scaling handled by Azure)
2️⃣ Supported Tech Stacks (Official)¶
| Category | Tech Stack |
|---|---|
| Frontend | React, Vue, Angular, Vite, Next.js (static or SSR*) |
| Backend | Node.js, Python, Java, .NET, PHP |
| APIs | Express, FastAPI, Spring Boot |
| Containers | Docker (any language) |
| Static | HTML, CSS, JS |
| Monorepo | Supported (with config) |
3️⃣ Core Concepts (Must Know)¶
🔹 App Service Plan¶
Defines:
-
OS (Linux / Windows)
-
CPU & RAM
-
Pricing Tier
| Tier | Use |
|---|---|
| Free / Shared | Testing |
| Basic | Small prod |
| Standard | Most apps |
| Premium | High traffic |
| Isolated | Enterprise |
🔹 Web App¶
-
Your actual application
-
Runs inside App Service Plan
4️⃣ Architecture Overview¶
5️⃣ Create Azure App Service (UI Method)¶
Step 1: Azure Portal¶
Step 2: Create Resource¶
Step 3: Basics¶
| Field | Value |
|---|---|
| Subscription | Your subscription |
| Resource Group | Create new |
| Name | my-app-service |
| Publish | Code / Docker |
| Runtime | Node / Python / Java / .NET |
| OS | Linux (recommended) |
| Region | Nearest |
| Plan | Basic / Standard |
Click Review + Create
6️⃣ Deployment Methods (Choose One)¶
| Method | Best For |
|---|---|
| GitHub Actions | Production |
| ZIP Deploy | Quick |
| FTP | Legacy |
| Azure CLI | Automation |
| Docker | Any language |
🔹 METHOD 1: GitHub Actions (RECOMMENDED)¶
7️⃣ GitHub Actions – General Flow¶
Azure generates a workflow file for you.
Azure will create:
-
Service Principal
-
Publish Profile
-
.github/workflows/deploy.yml
8️⃣ Tech Stack–Wise Deployment¶
🟢 A) Node.js / Express Backend¶
Project Structure¶
server.js¶
const express = require("express");
const app = express();
const PORT = process.env.PORT || 3000;
app.get("/", (req, res) => {
res.send("App running on Azure");
});
app.listen(PORT, () => {
console.log("Server started");
});
⚠️ IMPORTANT
-
❌ Do NOT hardcode port
-
✅ Use
process.env.PORT
package.json¶
GitHub Actions (Node.js)¶
name: Deploy Node App
on:
push:
branches: [main]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- run: npm install
- run: npm run build --if-present
- uses: azure/webapps-deploy@v2
with:
app-name: my-app-service
publish-profile: ${{ secrets.AZURE_PUBLISH_PROFILE }}
package: .
🟢 B) Python (FastAPI / Flask)¶
app.py¶
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def root():
return {"message": "Hello Azure"}
requirements.txt¶
Startup Command (Azure)¶
Set in:
🟢 C) Java (Spring Boot)¶
application.properties¶
Azure auto-detects port.
GitHub Actions¶
- run: mvn clean package
- uses: azure/webapps-deploy@v2
with:
app-name: my-java-app
package: target/*.jar
🟢 D) React / Vite Frontend¶
Build¶
App Service Type¶
-
Use Azure Static Web Apps (BEST)
OR -
App Service + Nginx
For App Service¶
Set:
🟢 E) Next.js¶
| Mode | Azure Support |
|---|---|
| Static | Static Web Apps |
| SSR | App Service (Node) |
SSR Startup¶
🟢 F) Docker (ANY STACK)¶
Dockerfile¶
Azure Settings¶
-
Publish: Docker Container
-
Image Source: GitHub / ACR / DockerHub
9️⃣ Environment Variables (.env)¶
Azure Way¶
Example:
👉 Automatically injected into runtime
🔐 10️⃣ HTTPS & SSL¶
✅ Azure provides FREE HTTPS
-
No cert files needed
-
Auto-renewed
Custom Domain¶
📈 11️⃣ Scaling¶
Vertical (Scale Up)¶
- Change pricing tier
Horizontal (Scale Out)¶
-
Auto-scale rules
-
CPU / Memory / Requests
📊 12️⃣ Logs & Monitoring¶
Enable Logs¶
View Logs¶
Advanced¶
-
Azure Monitor
-
Application Insights
🔁 13️⃣ Zero Downtime Deployments¶
Azure uses:
- Slot deployment
Flow¶
🔒 14️⃣ Security Best Practices¶
-
Use Managed Identity
-
Do not store secrets in repo
-
Enable HTTPS only
-
Restrict inbound IPs
-
Use Private DB endpoints
15️⃣ Common Mistakes ❌¶
| Mistake | Fix |
|---|---|
| Hardcoded port | Use env PORT |
| Local HTTPS cert | Remove |
| No start command | Define startup |
| Using Free tier in prod | Upgrade |
16️⃣ When NOT to Use App Service¶
❌ Heavy background jobs
❌ Complex microservices
❌ High-performance real-time systems
👉 Use AKS / VMs instead
17️⃣ Best Practice Architecture¶
Frontend → Azure Static Web Apps
Backend → Azure App Service
DB → Azure Managed DB
Cache → Azure Redis
CI/CD → GitHub Actions
✅ Final Summary¶
✔ Supports almost every stack
✔ No server maintenance
✔ Easy CI/CD
✔ Built-in SSL & scaling
✔ Ideal for startups & production