Deploying to Azure App Service
Managed PaaS on Azure for web apps, deploy from Git, container, or ZIP with autoscaling.
PlatformsAdvanced
Why
App Service is Azure's managed web hosting with built-in TLS, autoscaling, deployment slots, and AAD auth. It supports .NET, Node, Python, Java, and containers with one-click deploys.
When
Use App Service for enterprise Azure workloads, .NET apps, and teams already on Azure. Prefer Container Apps for containerized microservices.
How
1. Create — az webapp up --runtime NODE:20-lts
2. Git deploy — configure deployment source to GitHub repo
3. Container — az webapp config container set --docker-custom-image
4. Slots — deployment slots for staging, auto-swap on deploy
5. Autoscale — scale rule on CPU/memory
6. Connection strings — link to Azure SQL, Cosmos DB
7. Logs — az webapp log tail for streaming
Example
# Deploy Node.js app
az webapp up --name myapp --runtime "NODE:20-lts" --location eastus
# Deploy container
az webapp create --name myapp --plan myplan --deployment-container-image-name mycr.azurecr.io/app:v1
# Deployment slot for staging
az webapp deployment slot create --name myapp --slot staging
az webapp deployment slot auto-swap --name myapp --slot staging
# Scale rule
az monitor autoscale create --resource myapp --count 2 --min-count 1 --max-count 10
Common Problems
- ⚠App starts but 503 — wrong runtime version or startup command mismatch
- ⚠Slot swap fails — app settings sticky to slot, check slotSetting: true
- ⚠Configuration drift between environments — use infrastructure-as-code (Terraform/Pulumi) to keep dev/staging/prod identical
Best Practices
- ✓Use deployment slots for zero-downtime — deploy to staging, test, auto-swap to production
- ✓Set WEBSITES_PORT to match your app's port — avoids 503 from wrong port detection
- ✓Set up health checks and graceful shutdown — handle SIGTERM to drain in-flight requests before exit