Skip to content

Commit 8fcff6a

Browse files
committed
docs: update RUNBOOK.md
1 parent 63efa09 commit 8fcff6a

File tree

1 file changed

+129
-0
lines changed

1 file changed

+129
-0
lines changed

RUNBOOK.md

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# RUNBOOK — DevOps Starter Kit (App Service)
2+
3+
## Environments
4+
- Azure Web App: `devops-starter-webapp-dev31`
5+
- Resource group: `rg-devops-starter`
6+
- Region: Central India
7+
- Plan: F1 (Free), `always_on=false`
8+
9+
## Health & endpoints
10+
- Health: `GET /health``{"status":"ok"}`
11+
- Root: redirects to `/health`
12+
13+
## How to deploy (CI/CD)
14+
- Push to `main` → GitHub Actions runs `build-test` then `deploy`.
15+
- Secrets:
16+
- `AZURE_WEBAPP_PUBLISH_PROFILE` (repo secret)
17+
18+
## Manual deploy (fallback)
19+
1) Download publish profile from the Web App (Portal → Overview → Get publish profile).
20+
2) From VS Code:
21+
- Update code → commit → `git push`.
22+
- If CI is down: Portal → Deployment Center → “Sync” (uses last Good package).
23+
24+
25+
## Startup command (required for FastAPI)
26+
27+
gunicorn -w 2 -k uvicorn.workers.UvicornWorker app.main:app
28+
29+
Check/reset:
30+
```
31+
az webapp show -g rg-devops-starter -n devops-starter-webapp-dev31 --query siteConfig.appCommandLine -o tsv
32+
az webapp config set -g rg-devops-starter -n devops-starter-webapp-dev31 --startup-file "gunicorn -w 2 -k u
33+
34+
Rollback
35+
- Redeploy last green build from Actions (re-run - deploy on a previous successful run).
36+
37+
If app is unhealthy: Portal → Web App → Stop (emergency freeze).
38+
39+
Logs & debugging
40+
- az webapp log config -g rg-devops-starter -n - - devops-starter-webapp-dev31 --application-logging filesystem
41+
42+
```
43+
az webapp log tail -g rg-devops-starter -n devops-starter-webapp-dev31
44+
```
45+
46+
Terraform (infra)
47+
```
48+
cd terraform
49+
terraform plan
50+
terraform apply
51+
# Clean-up
52+
terraform destroy
53+
```
54+
55+
Security notes
56+
57+
- Never commit secrets.
58+
59+
- Rotate publish profile if leaked (Portal → Get publish profile).
60+
61+
```
62+
Then:
63+
```powershell
64+
git add RUNBOOK.md
65+
git commit -m "docs: add operational RUNBOOK"
66+
git push
67+
```
68+
69+
## 3) Add an Azure alert (proof you can operate it)
70+
71+
Copy-paste in PowerShell (same sub):
72+
```
73+
# IDs
74+
$RG = "rg-devops-starter"
75+
$APP = "devops-starter-webapp-dev31"
76+
$APPID = az webapp show -g $RG -n $APP --query id -o tsv
77+
78+
# Action Group to your email
79+
80+
az monitor action-group create -g $RG -n ag-email --action email DevNotify $EMAIL
81+
$AGID = az monitor action-group show -g $RG -n ag-email --query id -o tsv
82+
83+
# Alert: low CPU threshold (so it will actually trigger on F1)
84+
az monitor metrics alert create -g $RG -n cpu-gt-5 `
85+
--scopes $APPID `
86+
--condition "avg Percentage CPU > 5" `
87+
--window-size 5m --evaluation-frequency 1m `
88+
--action $AGID
89+
```
90+
91+
92+
Trigger some load to help it fire:
93+
94+
```
95+
$u = "https://devops-starter-webapp-dev31.azurewebsites.net/health"
96+
1..400 | % { Invoke-WebRequest $u -UseBasicParsing | Out-Null }
97+
```
98+
99+
Screenshot the alert rule + the email and commit as:
100+
101+
```
102+
evidence/09-alert-rule.png
103+
evidence/10-alert-email.png
104+
```
105+
106+
## 4) Repo cosmetics (fast wins)
107+
108+
- Description: “FastAPI demo with Docker, GitHub -Actions CI/CD to Azure App Service, Terraform IaC (foundational).”
109+
110+
- Topics: fastapi, docker, github-actions, terraform, azure, iac.
111+
112+
- License: add LICENSE (MIT).
113+
114+
```
115+
MIT License … (your name, year)
116+
```
117+
```
118+
git add LICENSE && git commit -m "chore: add MIT license" && git push
119+
```
120+
121+
## 5) CV/Interview hooks (use these exact lines)
122+
123+
- “Built a sandboxed CI/CD: ruff + pytest → GitHub Actions deploy to Azure Web App using publish profile secrets.”
124+
125+
- “Provisioned infra with Terraform (foundational): RG, Linux Plan, Web App, health check path.”
126+
127+
- “Set startup command (gunicorn+UvicornWorker), enabled HTTPS-only, added CPU alert with email action group.”
128+
129+
- “Rollback via re-deploy last green; logs via az webapp log tail.”

0 commit comments

Comments
 (0)