Azure App Service — CLI & PowerShell Cheat Sheet

IntermediateCheat Sheet12 min5 min read20 Jan 2025Azure

Essential Azure CLI and PowerShell commands for creating and managing App Service plans, web apps, deployment slots, scaling, and custom domains.

App Service Plans

# Create a plan (Linux, B2 SKU)
az appservice plan create \
  --resource-group myRG \
  --name myPlan \
  --sku B2 \
  --is-linux \
  --location eastus

# Create a plan (Windows, Standard S1)
az appservice plan create \
  --resource-group myRG \
  --name myWinPlan \
  --sku S1 \
  --location eastus

# List plans
az appservice plan list --resource-group myRG --output table

# Scale up plan (change SKU)
az appservice plan update \
  --resource-group myRG \
  --name myPlan \
  --sku P1V3

# Delete plan
az appservice plan delete --resource-group myRG --name myPlan
New-AzAppServicePlan -Name "myPlan" -Location "EastUS" -ResourceGroupName "myRG" -Tier "Standard" -NumberofWorkers 1 -WorkerSize "Small"
Get-AzAppServicePlan -ResourceGroupName "myRG"
Set-AzAppServicePlan -Name "myPlan" -ResourceGroupName "myRG" -Tier "Premium" -WorkerSize "Medium"

Web Apps

# Create a web app (Node 18, Linux)
az webapp create \
  --resource-group myRG \
  --plan myPlan \
  --name myapp-unique-name \
  --runtime "NODE:18-lts"

# Create a .NET 8 app
az webapp create \
  --resource-group myRG \
  --plan myPlan \
  --name myapp-unique-name \
  --runtime "DOTNETCORE:8.0"

# Create a Python 3.11 app
az webapp create \
  --resource-group myRG \
  --plan myPlan \
  --name myapp-unique-name \
  --runtime "PYTHON:3.11"

# List available runtimes
az webapp list-runtimes --os-type linux

# List all web apps
az webapp list --resource-group myRG --output table

# Show detail
az webapp show --resource-group myRG --name myapp-unique-name

# Delete web app
az webapp delete --resource-group myRG --name myapp-unique-name

Deployment

# Deploy from local ZIP
az webapp deployment source config-zip \
  --resource-group myRG \
  --name myapp-unique-name \
  --src app.zip

# Configure GitHub Actions deployment
az webapp deployment github-actions add \
  --resource-group myRG \
  --name myapp-unique-name \
  --repo "https://github.com/user/repo" \
  --branch main

# Set Git deployment credentials
az webapp deployment user set \
  --user-name myuser \
  --password "P@ssw0rd!"

# Enable local Git deployment and get remote URL
az webapp deployment source config-local-git \
  --resource-group myRG \
  --name myapp-unique-name

# View deployment logs
az webapp log deployment show \
  --resource-group myRG \
  --name myapp-unique-name

Deployment Slots

# Create a staging slot
az webapp deployment slot create \
  --resource-group myRG \
  --name myapp-unique-name \
  --slot staging

# Deploy to staging slot
az webapp deployment source config-zip \
  --resource-group myRG \
  --name myapp-unique-name \
  --slot staging \
  --src app.zip

# Swap staging → production
az webapp deployment slot swap \
  --resource-group myRG \
  --name myapp-unique-name \
  --slot staging \
  --target-slot production

# List slots
az webapp deployment slot list \
  --resource-group myRG \
  --name myapp-unique-name \
  --output table

# Delete a slot
az webapp deployment slot delete \
  --resource-group myRG \
  --name myapp-unique-name \
  --slot staging

App Settings & Connection Strings

# Set app settings (env vars)
az webapp config appsettings set \
  --resource-group myRG \
  --name myapp-unique-name \
  --settings KEY1=value1 KEY2=value2

# List app settings
az webapp config appsettings list \
  --resource-group myRG \
  --name myapp-unique-name

# Delete a setting
az webapp config appsettings delete \
  --resource-group myRG \
  --name myapp-unique-name \
  --setting-names KEY1

# Set connection string
az webapp config connection-string set \
  --resource-group myRG \
  --name myapp-unique-name \
  --connection-string-type SQLAzure \
  --settings MyConn="Server=tcp:myserver.database.windows.net;..."

Scaling

# Scale out manually (change instance count on plan)
az appservice plan update \
  --resource-group myRG \
  --name myPlan \
  --number-of-workers 3

# Create autoscale setting
az monitor autoscale create \
  --resource-group myRG \
  --resource myPlan \
  --resource-type Microsoft.Web/serverFarms \
  --name myAutoscale \
  --min-count 1 --max-count 10 --count 2

# Scale out rule (CPU > 70%)
az monitor autoscale rule create \
  --resource-group myRG \
  --autoscale-name myAutoscale \
  --condition "CpuPercentage > 70 avg 5m" \
  --scale out 2

# Scale in rule (CPU < 30%)
az monitor autoscale rule create \
  --resource-group myRG \
  --autoscale-name myAutoscale \
  --condition "CpuPercentage < 30 avg 5m" \
  --scale in 1

Custom Domains & SSL

# Add custom domain (DNS must already point to app)
az webapp config hostname add \
  --resource-group myRG \
  --webapp-name myapp-unique-name \
  --hostname "www.example.com"

# Create a managed certificate (free, Standard+ plan)
az webapp config ssl create \
  --resource-group myRG \
  --name myapp-unique-name \
  --hostname "www.example.com"

# Bind SSL certificate
az webapp config ssl bind \
  --resource-group myRG \
  --name myapp-unique-name \
  --certificate-thumbprint <thumbprint> \
  --ssl-type SNI

# List certificates
az webapp config ssl list --resource-group myRG

# Enforce HTTPS only
az webapp update \
  --resource-group myRG \
  --name myapp-unique-name \
  --https-only true

Logging & Diagnostics

# Enable application logging to filesystem
az webapp log config \
  --resource-group myRG \
  --name myapp-unique-name \
  --application-logging filesystem \
  --level information

# Stream live logs
az webapp log tail \
  --resource-group myRG \
  --name myapp-unique-name

# Download logs as ZIP
az webapp log download \
  --resource-group myRG \
  --name myapp-unique-name \
  --log-file mylogs.zip

# Show current log config
az webapp log show \
  --resource-group myRG \
  --name myapp-unique-name

Networking & Access

# Restrict access to specific IP
az webapp config access-restriction add \
  --resource-group myRG \
  --name myapp-unique-name \
  --rule-name "OfficeIP" \
  --action Allow \
  --ip-address 203.0.113.10/32 \
  --priority 100

# Enable VNet integration
az webapp vnet-integration add \
  --resource-group myRG \
  --name myapp-unique-name \
  --vnet myVNet \
  --subnet mySubnet

# List VNet integration
az webapp vnet-integration list \
  --resource-group myRG \
  --name myapp-unique-name

Key Facts for AZ-104

ConceptDetail
Free / SharedNo SLA; shared infrastructure; no custom domain SSL
BasicDedicated; custom domain; manual scale only
StandardSlots (5); autoscale; daily backups
PremiumSlots (20); VNet integration; more scale
IsolatedApp Service Environment (ASE); VNet injection
Slot swapZero-downtime deploy; settings marked "sticky" stay per-slot
Always OnKeeps app loaded; required for WebJobs; Standard+
Deployment slotsEach slot is an independent app with its own URL

More in Microsoft Azure