Configuring Website Deployment on Azure (App Service)
Azure App Service is a PaaS platform for web applications. Supports Node.js, PHP, Python, .NET, Java. Built-in CI/CD via GitHub Actions, Deployment Slots for staging, autoscaling.
Creating App Service
# Azure CLI
az group create --name myapp-rg --location westeurope
az appservice plan create \
--name myapp-plan \
--resource-group myapp-rg \
--sku B2 \
--is-linux
az webapp create \
--name myapp-prod \
--resource-group myapp-rg \
--plan myapp-plan \
--runtime "PHP|8.3"
Configuration via Azure CLI
# Environment variables
az webapp config appsettings set \
--name myapp-prod \
--resource-group myapp-rg \
--settings \
APP_ENV=production \
APP_KEY="base64:..." \
DB_HOST="myserver.postgres.database.azure.com" \
DB_DATABASE=myapp \
WEBSITES_PORT=8000
# Connect PostgreSQL
az postgres flexible-server create \
--name myapp-db \
--resource-group myapp-rg \
--location westeurope \
--sku-name Standard_B1ms \
--storage-size 32 \
--admin-user dbadmin \
--admin-password "$DB_PASSWORD"
Deployment Slots
Deployment Slots are separate environments within one App Service. Perfect for staging:
# Create staging slot
az webapp deployment slot create \
--name myapp-prod \
--resource-group myapp-rg \
--slot staging
# Deploy to staging
az webapp deploy \
--name myapp-prod \
--resource-group myapp-rg \
--slot staging \
--src-path deployment.zip
# Swap staging → production (instant, zero-downtime)
az webapp deployment slot swap \
--name myapp-prod \
--resource-group myapp-rg \
--slot staging \
--target-slot production
# Swap Back if something went wrong
az webapp deployment slot swap \
--name myapp-prod \
--resource-group myapp-rg \
--slot production \
--target-slot staging
GitHub Actions + Azure Web App
# .github/workflows/azure-deploy.yml
name: Deploy to Azure
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with: { php-version: '8.3' }
- name: Install dependencies
run: composer install --no-dev --optimize-autoloader
- name: Build frontend
run: npm ci && npm run build
- name: Deploy to Azure Web App
uses: azure/webapps-deploy@v3
with:
app-name: myapp-prod
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
package: .
Docker Deployment
# Create Azure Container Registry
az acr create \
--name myappcr \
--resource-group myapp-rg \
--sku Basic
# Build and push
az acr build \
--registry myappcr \
--image myapp:$GITHUB_SHA \
.
# Update App Service
az webapp config container set \
--name myapp-prod \
--resource-group myapp-rg \
--container-image-name myappcr.azurecr.io/myapp:$GITHUB_SHA
Autoscaling
az monitor autoscale create \
--resource-group myapp-rg \
--resource myapp-plan \
--resource-type Microsoft.Web/serverfarms \
--name autoscale-rule \
--min-count 2 \
--max-count 10 \
--count 2
az monitor autoscale rule create \
--autoscale-name autoscale-rule \
--resource-group myapp-rg \
--scale out 2 \
--condition "Percentage CPU > 75 avg 5m"
Implementation Timeline
- Basic App Service deployment + GitHub Actions: 1–2 days
- Deployment Slots + swap: +1 day
- Terraform for full infrastructure: 3–4 days







