Full Course / Workshop
Build a real cloud-native feature with AI, ship it to Kubernetes on Azure, break it on purpose, and fix it with an SRE Agent. The closed loop: Build → Ship → Break → Diagnose → Remediate.
What it is. Read in order, one lesson at a time. Tick the Done box when you finish a lesson. Your progress is saved in your browser. Every lesson has the same shape: What it is, Why it matters, code or examples you can copy, a small task to try yourself, and two check questions with the answers hidden until you open them. The workshop has two halves: first you build a small service, then the same service becomes a production incident you diagnose and fix.
Why it matters. A workshop only works if you do it, not just read it. The tick boxes and the small tasks keep you moving, one small step at a time, from a written specification to a service running live — and back from a broken service to a healthy one.
# No code to run in this lesson.
# Just read the plan below, then start with Setup.
print('Ready. Start with Setup.')
print('The loop: Build -> Ship -> Break -> Diagnose -> Remediate')
Try it yourself. Tick the Done box on this lesson and watch the progress bar move.
Check yourself.
Build, then Ship, then Break, then Diagnose, then Remediate. The same feature you build in the first half becomes the production incident in the second half.
No. That is the point: the feature you create in the first half is the one that breaks in the second half, so you see the whole lifecycle of one real service.
What it is. You need: a GitHub account (for the repo and GitHub Copilot), Python 3.10 or newer, Docker (to build and run containers on your own computer), and kubectl (the command-line tool that talks to Kubernetes). For the real cloud steps you need an Azure account, because AKS (Azure Kubernetes Service) and Azure SRE Agent run on Azure. Important, in plain words: AKS and Azure SRE Agent need an Azure account and can cost money. A small AKS cluster costs real money every hour it runs, so delete it when you finish. The good news: everything you practise on this page runs offline on your own computer, with a simulated service and a simulated SRE Agent. No Azure account and no API key is needed for the practice here. For the Kubernetes parts, the local alternative is kind or minikube — small Kubernetes clusters that run on your own computer for free.
Why it matters. If setup is hard, you never start. So this page lets you learn the whole loop for free on your own computer first, and only spend money on Azure when you are ready to run the real thing.
# Check your tools (run in your terminal, not here):
# python3 --version # need 3.10 or newer
# docker --version # to build and run containers
# kubectl version --client # to talk to Kubernetes
# gh --version # GitHub CLI, optional but handy
# kind --version # local Kubernetes, free alternative to AKS
# az --version # Azure CLI, only for the real AKS steps
print('Setup checklist:')
for tool in ['Python 3.10+', 'Docker', 'kubectl', 'GitHub account', 'kind or minikube (free local Kubernetes)']:
print('[ ]', tool)
print('Azure account: only needed for the real AKS + SRE Agent steps (costs money).')
Try it yourself. Run the checklist above in your terminal. Tick off each tool you already have, and install the missing ones before the next lesson.
Check yourself.
AKS (Azure Kubernetes Service) and Azure SRE Agent, because they run on Azure. Delete the cluster when you finish so the cost stops.
kind or minikube — a small Kubernetes cluster that runs on your own computer for free.
What it is. Most AI-for-developers content stops at code generation: ask the AI to write a function, and stop there. This workshop goes much further. You watch a real cloud-native feature move through its full lifecycle: from a specification, to AI-assisted implementation, to deployment on Azure Kubernetes Service, to a live production incident investigated and remediated with Azure SRE Agent. Cloud-native means the software is built to run in containers on a cloud platform, not on one single computer. A container is a small sealed box that holds your app and everything it needs to run, so it runs the same way anywhere. Kubernetes is the system that runs and watches many containers for you. AKS is Microsoft Azure's managed Kubernetes — Kubernetes run for you on Azure. An SRE Agent is an AI agent for site reliability engineering: it reads logs, metrics, and traces and helps find why a live system is failing.
Why it matters. Code generation is the easy 10 percent. The hard part — and the part that matters at work — is everything after: does it run, does it stay up, and what do you do when it breaks at 2 a.m.? That is what this workshop teaches.
# The full lifecycle, as a list you will walk through.
lifecycle = [
"1. Specification - write down what the feature must do",
"2. Implementation - build it with AI help (Copilot harness)",
"3. Container - pack it in a Docker container",
"4. Deployment - ship it to AKS (Kubernetes on Azure)",
"5. Incident - break it, on purpose",
"6. Investigation - Azure SRE Agent finds the root cause",
"7. Remediation - fix it, redeploy, verify it is healthy",
]
for step in lifecycle:
print(step)
Try it yourself. Write down, in one sentence, a feature you would like to take through this lifecycle at your own work.
Check yourself.
Software built to run in containers on a cloud platform, instead of on one single computer.
Azure Kubernetes Service — Microsoft Azure's managed Kubernetes, a service that runs and watches your containers for you on Azure.
What it is. The key difference in this workshop is the closed loop: Build, Ship, Break, Diagnose, Remediate. The same feature created in the first half becomes the production incident in the second half. You build a small quote service, ship it to Kubernetes, break it on purpose with a bad config or a slow dependency, watch the SRE Agent investigate it, fix the real root cause, and redeploy. The loop is closed because the fix goes back into the repository as code, and the next run of the loop is safer than the last one. A runbook is a written step-by-step guide for handling an incident: what to check first, what commands to run, and when to call a human. Root cause is the real underlying reason something failed, not the first symptom you see.
Why it matters. Seeing the whole loop on one feature changes how you write code. When you know your code will break in production and be investigated, you write better logs, better health checks, and clearer specs — because you will be the one reading them during the incident.
# The closed loop, as a loop you can run again and again.
loop = ["Build", "Ship", "Break", "Diagnose", "Remediate"]
print(" -> ".join(loop) + " -> (again)")
print()
print("Each time round the loop, the service gets safer:")
print("- the Copilot harness learns a new rule")
print("- the runbook gains a new step")
print("- the tests cover the failure that just happened")
Try it yourself. Draw the five steps of the loop on paper, and under each one write one thing you will do in that step for the quote service.
Check yourself.
A written step-by-step guide for handling an incident: what to check first, what commands to run, and when to call a human.
Root cause is the real underlying reason something failed. A symptom is what you see — for example, a slow page. The root cause might be a missing database index.
What it is. By the end of the workshop, you will be able to: (1) Build a GitHub Copilot harness that aligns generated code with team standards. (2) Implement a feature from a specification with tests, logging, and operational requirements. (3) Deploy a containerized service to AKS. (4) Use Azure SRE Agent to investigate failures and identify root cause. (5) Connect code-level findings back to the repository. (6) Decide what should be automated and what should remain behind human approval. You should walk away with: a public GitHub repo containing the full lab, infrastructure, application code, Copilot harness, break scenarios, and replay guide; a reusable GitHub Copilot harness template; prompt and runbook examples for Azure SRE Agent; a checklist for adapting the workflow to your own services; and guidance on cost, governance, and human approval boundaries.
Why it matters. These are the outcomes employers actually want. Not 'I can ask an AI to write code', but 'I can ship a service, watch it in production, find out why it broke, and fix it properly'.
# The six outcomes and the five things you walk away with.
outcomes = [
"1. Build a GitHub Copilot harness aligned with team standards",
"2. Implement a feature from a spec, with tests, logging, and ops requirements",
"3. Deploy a containerized service to AKS",
"4. Use Azure SRE Agent to investigate failures and find root cause",
"5. Connect code-level findings back to the repository",
"6. Decide what to automate and what stays behind human approval",
]
takeaways = [
"A public GitHub repo: lab, infrastructure, app code, harness, break scenarios, replay guide",
"A reusable GitHub Copilot harness template",
"Prompt and runbook examples for Azure SRE Agent",
"A checklist for adapting the workflow to your own services",
"Guidance on cost, governance, and human approval boundaries",
]
print("YOU WILL BE ABLE TO:")
for o in outcomes:
print(" " + o)
print()
print("YOU WALK AWAY WITH:")
for t in takeaways:
print(" - " + t)
Try it yourself. Which of the six outcomes matters most for your job right now? Write it down and keep it in mind as you go.
Check yourself.
A set of rules, instructions, and checks that guide GitHub Copilot so the code it writes matches your team's standards instead of random style.
Written steps to run the whole loop again — build, ship, break, diagnose, remediate — on your own, or with your team.
What it is. A specification (spec) is a short written document that says exactly what a feature must do, before anyone writes code. A good spec has: the goal in one sentence, the endpoints (the web addresses the service answers), what each endpoint returns, the rules (what counts as valid), and the operational requirements (health checks, logging, how fast it must answer). Our worked example for the whole workshop is a small quote service: GET /quote returns one quote of the day, GET /health returns OK if the service is alive, and GET /quotes returns the list of quotes. Rules: /quote must answer in under 1 second, /health must never need the database, and every request must be logged.
Why it matters. AI writes much better code when the spec is clear. A vague spec gives vague code. A precise spec gives code you can test — and the spec is also what the SRE Agent reads later when it investigates an incident.
# The spec, written as data — so you can check code against it.
spec = {
"service": "quote-service",
"goal": "Return one quote of the day over HTTP.",
"endpoints": {
"/quote": "GET - returns one quote as JSON: {quote, author}",
"/quotes": "GET - returns the list of all quotes as JSON",
"/health": "GET - returns {status: ok}, must not need the database",
},
"rules": [
"/quote must answer in under 1 second",
"/health must answer in under 0.1 seconds",
"Every request must be logged with method, path, and time",
],
}
for key, value in spec["endpoints"].items():
print(key, "->", value)
print()
print("Rules:")
for rule in spec["rules"]:
print(" -", rule)
Try it yourself. Write a one-sentence goal and two endpoints for a feature of your own, in the same shape as the spec above.
Check yourself.
A short written document that says exactly what a feature must do, before anyone writes code.
So the health check still answers OK even when the database is down — otherwise Kubernetes cannot tell whether the app itself is alive.
What it is. A GitHub Copilot harness is a set of files in your repository that tell Copilot how to write code for your team. The main file is .github/copilot-instructions.md: a plain markdown file with your team's rules. The harness also includes code-review rules (what a reviewer checks before code is merged) and a template you can reuse in every repo. Copilot reads these instructions every time it suggests code, so the generated code follows your standards: Python 3.10+, type hints, tests for every endpoint, logging on every request, no secrets in code, and short functions.
Why it matters. Without a harness, Copilot writes code in whatever style it guesses. With a harness, every suggestion already matches your team — so code review is faster, and the code that reaches production is consistent.
# Copilot harness template — save as .github/copilot-instructions.md
HARNESS = """# Copilot instructions — quote-service
## Stack
- Python 3.10+, standard library only (no extra dependencies).
- One small service, one file per concern: app.py, quotes.py, test_app.py.
## Style rules
- Short functions (under 20 lines). Clear names. Type hints on every function.
- No secrets or passwords in code. Read config from environment variables.
- Log every request: method, path, status, time in milliseconds.
## Testing rules
- Every endpoint must have at least one test.
- Tests must pass before any code is merged: python -m unittest.
## Operational rules
- /health must answer without the database.
- Every endpoint must answer in under 1 second.
- Return JSON errors, never a crash page.
"""
print(HARNESS)
print("Saved to: .github/copilot-instructions.md")
Try it yourself. Copy the harness above into a file called copilot-instructions.md, then add one rule of your own that your team would want.
Check yourself.
A set of files in your repo — mainly .github/copilot-instructions.md — that tell GitHub Copilot your team's rules, so generated code matches your standards.
In the repository itself, in the .github folder, so every developer and every Copilot suggestion uses the same rules.
What it is. Now implement the quote service from the spec, with Copilot's help. The prompt pattern that works: give Copilot the spec, the harness rules, and one small step at a time — first the /health endpoint, then /quote, then /quotes. Ask for tests at the same time as the code, not after. Check every suggestion against the spec before you accept it: does it match the endpoint, the JSON shape, and the rules? The service below is the full implementation, written to the spec: it uses only the Python standard library, so you can run it with plain python3 and no installs.
Why it matters. Small steps keep you in control. If you ask for the whole service at once, you get a big block of code you cannot check. One endpoint at a time means every piece is checked against the spec as it is written.
# app.py — the quote service, written to the spec (stdlib only, runs as-is).
import json
import logging
import time
from http.server import BaseHTTPRequestHandler, HTTPServer
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(message)s")
QUOTES = [
{"quote": "Simplicity is the soul of efficiency.", "author": "Austin Freeman"},
{"quote": "First, solve the problem. Then, write the code.", "author": "John Johnson"},
{"quote": "The best error message is the one that never shows up.", "author": "Thomas Fuchs"},
]
class Handler(BaseHTTPRequestHandler):
def _send(self, status, data):
body = json.dumps(data).encode()
self.send_response(status)
self.send_header("Content-Type", "application/json")
self.send_header("Content-Length", str(len(body)))
self.end_headers()
self.wfile.write(body)
def do_GET(self):
start = time.time()
if self.path == "/health":
self._send(200, {"status": "ok"})
elif self.path == "/quote":
self._send(200, QUOTES[int(time.time() // 86400) % len(QUOTES)])
elif self.path == "/quotes":
self._send(200, QUOTES)
else:
self._send(404, {"error": "not found"})
ms = (time.time() - start) * 1000
logging.info("GET %s -> %d in %.1fms", self.path, 200, ms)
def log_message(self, *args):
pass # we log in do_GET instead
if __name__ == "__main__":
print("Quote service on http://localhost:8000 (try /health and /quote)")
HTTPServer(("0.0.0.0", 8000), Handler).serve_forever()
Try it yourself. Save the code above as app.py and run it with python3 app.py, then open http://localhost:8000/health in your browser. You should see {"status": "ok"}.
Check yourself.
So you can check each piece against the spec as it is written, instead of getting a big block of code you cannot review.
So it runs with plain python3 and no installs — and so the container stays small and simple.
What it is. Operational requirements are the promises a service makes about running, not just about working: health checks, logging, metrics (numbers about how the service is doing, like request count and response time), and configuration from environment variables instead of hard-coded values. Tests prove the spec holds: /health returns OK, /quote returns a quote with an author, an unknown path returns 404 JSON. Logging means every request is written down with method, path, and time, so the SRE Agent has something to read during an incident. A health check is a small endpoint that answers 'I am alive' without doing real work.
Why it matters. Tests catch mistakes before users do. Logs are the only record of what happened during an incident. If you skip either, the second half of this workshop — diagnosis — has nothing to work with.
# test_app.py — tests for the quote service (stdlib unittest, runs as-is).
# Save next to app.py, then run: python3 -m unittest test_app -v
import json
import unittest
from unittest.mock import patch
from io import BytesIO
import app
class FakeRequest:
def makefile(self, *a, **k):
return BytesIO(b"GET /health HTTP/1.1\r\nHost: x\r\n\r\n")
def sendall(self, data):
self.sent = data
def call(path):
"""Call the handler logic for one path and return (status, body)."""
handler = app.Handler.__new__(app.Handler)
handler.path = path
handler.wfile = BytesIO()
handler.send_response = lambda s: setattr(handler, "status", s)
handler.send_header = lambda *a: None
handler.end_headers = lambda: None
handler.do_GET()
body = handler.wfile.getvalue()
return handler.status, json.loads(body)
class TestQuoteService(unittest.TestCase):
def test_health_returns_ok(self):
status, body = call("/health")
self.assertEqual(status, 200)
self.assertEqual(body, {"status": "ok"})
def test_quote_has_quote_and_author(self):
status, body = call("/quote")
self.assertEqual(status, 200)
self.assertIn("quote", body)
self.assertIn("author", body)
def test_quotes_returns_list(self):
status, body = call("/quotes")
self.assertEqual(status, 200)
self.assertTrue(isinstance(body, list))
self.assertGreater(len(body), 0)
def test_unknown_path_returns_404_json(self):
status, body = call("/nope")
self.assertEqual(status, 404)
self.assertIn("error", body)
if __name__ == "__main__":
unittest.main()
Try it yourself. Save the tests as test_app.py next to app.py and run: python3 -m unittest test_app -v. All four tests should pass.
Check yourself.
A small endpoint, like /health, that answers 'I am alive' without doing real work, so Kubernetes can tell whether the app is running.
Numbers about how the service is doing — request count, response time, error rate — that you watch to spot problems early.
What it is. A container is a small sealed box that holds your app and everything it needs to run — the Python version, your code, and the command to start it — so it runs the same way on your computer, on a teammate's computer, and on Azure. A Dockerfile is the recipe for building that box: start from a Python image, copy the code in, and say how to start the service. You build the image with docker build, run it with docker run, and check it with curl. If it works in the container on your computer, it will work the same way on Kubernetes.
Why it matters. 'It works on my computer' is the most common deployment failure. A container removes that excuse: the box is the same everywhere, so what you test locally is what ships.
# Dockerfile — the recipe for the quote-service container.
DOCKERFILE = """FROM python:3.12-slim
WORKDIR /app
COPY app.py .
ENV PORT=8000
EXPOSE 8000
CMD ["python3", "app.py"]
"""
print(DOCKERFILE)
print("Build and run (in your terminal):")
print(" docker build -t quote-service:1.0 .")
print(" docker run -p 8000:8000 quote-service:1.0")
print(' curl http://localhost:8000/health # expect {"status": "ok"}')
print(' curl http://localhost:8000/quote # expect one quote as JSON')
Try it yourself. Copy the Dockerfile above into the same folder as app.py, then run docker build -t quote-service:1.0 . in your terminal.
Check yourself.
A small sealed box holding your app and everything it needs to run, so it runs the same way anywhere.
The recipe for building a container: which base image, which files to copy in, and how to start the app.
What it is. Kubernetes is the system that runs and watches your containers for you. You describe what you want — 'run 3 copies of the quote service, restart any copy that fails, and send traffic to the healthy ones' — and Kubernetes makes it happen and keeps it happening. The pieces: a Pod is one running copy of your container. A Deployment says how many copies to run and how to update them. A Service gives the copies one stable address, so other things can find them. An Ingress is the front door from the internet. A ConfigMap holds configuration (like the port number) separately from the code. AKS — Azure Kubernetes Service — is Kubernetes run for you on Microsoft Azure, so you do not manage the servers yourself.
Why it matters. You do not babysit servers any more. You describe the desired state, and Kubernetes keeps reality matching it — restarting dead pods, spreading copies, and rolling out new versions one pod at a time.
# The Kubernetes pieces for the quote service, in plain words.
pieces = [
("Pod", "One running copy of the quote-service container."),
("Deployment", "Says: run 3 copies, restart any that fail, roll out updates one at a time."),
("Service", "One stable address for the 3 copies, so traffic finds a healthy one."),
("Ingress", "The front door from the internet to the Service."),
("ConfigMap", "Configuration (like PORT=8000) kept apart from the code."),
("AKS", "Azure Kubernetes Service — Kubernetes run for you on Azure."),
]
for name, meaning in pieces:
print(f"{name:12s} {meaning}")
print()
print("Desired state: 3 healthy copies. Kubernetes keeps it true, day and night.")
Try it yourself. Write down, in your own words, what a Pod and a Deployment are, and how they are different.
Check yourself.
One running copy of your container.
Azure Kubernetes Service — Kubernetes run for you on Microsoft Azure, so you do not manage the servers yourself.
What it is. To deploy, you write manifests — YAML files that describe the Deployment, Service, and ConfigMap — and apply them with kubectl, the command-line tool for Kubernetes. kubectl apply -f deployment.yaml sends the description to the cluster. kubectl rollout status watches the new version roll out pod by pod. kubectl get pods shows whether the copies are running, and kubectl logs reads what they printed. A rollout is the safe way to update: Kubernetes starts one new pod, waits for its health check, then replaces the next one, so the service never goes down. The manifests below deploy 3 copies of the quote service, with the port from a ConfigMap, a /health check, and memory limits.
Why it matters. Manifests are the contract with Kubernetes. They are stored in the repo, reviewed like code, and versioned — so you always know exactly what is running, and you can roll it back.
# deployment.yaml — Deployment + Service + ConfigMap for the quote service.
MANIFEST = """apiVersion: v1
kind: ConfigMap
metadata:
name: quote-config
data:
PORT: "8000"
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: quote-service
spec:
replicas: 3
selector:
matchLabels:
app: quote-service
template:
metadata:
labels:
app: quote-service
spec:
containers:
- name: quote-service
image: quote-service:1.0
ports:
- containerPort: 8000
env:
- name: PORT
valueFrom:
configMapKeyRef:
name: quote-config
key: PORT
resources:
limits:
memory: "256Mi"
livenessProbe:
httpGet:
path: /health
port: 8000
initialDelaySeconds: 5
periodSeconds: 10
---
apiVersion: v1
kind: Service
metadata:
name: quote-service
spec:
selector:
app: quote-service
ports:
- port: 80
targetPort: 8000
"""
print(MANIFEST)
print("Deploy (in your terminal):")
print(" kubectl apply -f deployment.yaml")
print(" kubectl rollout status deployment/quote-service")
print(" kubectl get pods")
print(" kubectl logs deployment/quote-service")
Try it yourself. Copy the manifest above into a file called deployment.yaml, and read it line by line. Find the livenessProbe and say, in your own words, what it checks.
Check yourself.
A YAML file that describes what you want Kubernetes to run — the Deployment, Service, and ConfigMap for your service.
The safe way to update: Kubernetes starts one new pod, waits for its health check, then replaces the next one, so the service never goes down.
What it is. Before you spend money on AKS, deploy the same manifests on your own computer with kind or minikube. kind (Kubernetes in Docker) creates a small cluster inside Docker with one command: kind create cluster. minikube does the same with a virtual machine. Then you run the exact same kubectl commands as on AKS: kubectl apply, kubectl get pods, kubectl logs. The only difference is the cluster address. This is the safe place to practise the break scenarios too — breaking your own laptop costs nothing.
Why it matters. Practise the whole loop for free first. When the manifests work locally, they will work on AKS, because Kubernetes is the same system in both places.
# Local Kubernetes practice (run in your terminal, not here).
COMMANDS = [
"kind create cluster --name workshop # or: minikube start",
"kubectl cluster-info # check you are connected",
"kind load docker-image quote-service:1.0 --name workshop # kind only",
"kubectl apply -f deployment.yaml",
"kubectl get pods -w # watch the 3 pods become Ready",
"kubectl port-forward service/quote-service 8080:80",
"# then open http://localhost:8080/health in your browser",
"kind delete cluster --name workshop # clean up when done",
]
for cmd in COMMANDS:
print(cmd)
Try it yourself. If you have kind installed, run kind create cluster --name workshop in your terminal, then kubectl get pods. If not, install kind first.
Check yourself.
Kubernetes in Docker — a small Kubernetes cluster that runs on your own computer for free, for practice.
Because it is free, and the same manifests and kubectl commands work in both places — so a local success predicts an AKS success.
What it is. A break scenario is a fault you cause on purpose, in a safe place, to practise finding and fixing it. Scenario 1: someone changes the ConfigMap so PORT is 8080, but the Deployment and Service still expect 8000. The app starts, binds port 8080, and the health check on port 8000 fails. Kubernetes kills the pod and starts a new one — which fails the same way. The pod restarts again and again, and no request ever succeeds. The symptom is 'the service is down and the pods keep restarting'. The cause is a one-line config mistake. The script below simulates it: it starts the service on the wrong port and shows the health check failing.
Why it matters. Config mistakes are the most common real incidents, and the cheapest to prevent. This scenario teaches you to check the config first — before blaming the code.
# break_bad_config.py — simulate the bad-config incident (stdlib only).
# The app listens on 8080, but the health check calls 8000. Watch it fail.
import json
import threading
import time
import urllib.request
import urllib.error
from http.server import BaseHTTPRequestHandler, HTTPServer
class Handler(BaseHTTPRequestHandler):
def do_GET(self):
body = json.dumps({"status": "ok"}).encode()
self.send_response(200)
self.send_header("Content-Length", str(len(body)))
self.end_headers()
self.wfile.write(body)
def log_message(self, *a):
pass
WRONG_PORT = 8080 # the ConfigMap says 8080...
EXPECTED_PORT = 8000 # ...but the health check calls 8000
server = HTTPServer(("127.0.0.1", WRONG_PORT), Handler)
threading.Thread(target=server.serve_forever, daemon=True).start()
restarts = 0
for attempt in range(1, 4):
try:
with urllib.request.urlopen(f"http://127.0.0.1:{EXPECTED_PORT}/health", timeout=1) as r:
print("health check:", r.status)
except Exception as e:
restarts += 1
print(f"attempt {attempt}: health check FAILED ({type(e).__name__}) -> Kubernetes restarts the pod")
time.sleep(0.2)
print(f"Pod restarts: {restarts} in a row. Symptom: service down, pods restarting.")
print("Cause to find: ConfigMap PORT=8080, but the Service expects 8000.")
server.shutdown()
Try it yourself. Run the script above. Then change WRONG_PORT to 8000 and run it again — the health check should now pass. That is the fix.
Check yourself.
A fault you cause on purpose, in a safe place, to practise finding and fixing it before it happens for real.
The health check fails, so Kubernetes kills the pod and starts a new one — which fails the same way, because the config is still wrong.
What it is. Scenario 2: the quote database becomes very slow — a missing index means every lookup scans the whole table. The app itself is fine, but it waits 8 seconds for the database, and the request timeout is 5 seconds, so users see failures. The symptom is 'the page is slow and sometimes fails'. The pods look healthy — CPU and memory are normal — so restarting them does nothing. The script below simulates it: a lookup that should take 0.2 seconds now takes 8, and the 5-second timeout fires.
Why it matters. This scenario teaches the most important diagnosis lesson: a slow service is not always a broken service. Sometimes it is waiting on something else. Check the dependency before you restart the app.
# break_slow_dep.py — simulate a slow dependency (stdlib only).
import time
def lookup_quote_slow():
"""Simulates a database lookup with a missing index: scans everything."""
time.sleep(2) # shortened from 8s so the demo is quick; real case: 8s
return {"quote": "Slow and steady.", "author": "Demo"}
def lookup_quote_fast():
"""With an index, the same lookup is instant."""
return {"quote": "Slow and steady.", "author": "Demo"}
TIMEOUT_SECONDS = 1 # shortened from 5s for the demo
for name, fn in [("slow (no index)", lookup_quote_slow), ("fast (indexed)", lookup_quote_fast)]:
start = time.time()
result = fn()
took = time.time() - start
status = "TIMEOUT - user sees a failure" if took > TIMEOUT_SECONDS else "OK"
print(f"{name}: took {took:.1f}s, timeout is {TIMEOUT_SECONDS}s -> {status}")
print()
print("Real incident numbers: lookup 8s, timeout 5s, p95 latency 8.1s, 40% of requests fail.")
print("Pods look healthy (CPU and memory normal) — restarting them fixes nothing.")
Try it yourself. Run the script above. Then change the sleep from 2 to 0.5 and run again — what happens to the timeout verdict?
Check yourself.
The response time that 95 out of 100 requests are faster than. If p95 is 8 seconds, most users are waiting 8 seconds.
Because the app is not the problem — it is waiting on the database. A fresh pod waits just as long.
What it is. Scenario 3: at startup the app loads the entire quotes table into memory instead of reading one quote at a time. The memory limit in the Deployment is 256Mi (256 megabytes). The table needs more than that, so the pod is killed with OOMKilled — Out Of Memory Killed — after about 30 seconds, then Kubernetes starts it again, and it is killed again. The symptom is 'the pod starts, runs for 30 seconds, then dies'. The script below simulates it: it grows a list until it passes a small memory budget, the way the real app grows past 256Mi.
Why it matters. Memory limits protect the cluster: one greedy pod cannot eat all the memory. But a limit that is too small for what the app actually does will kill a healthy app. The fix is both code (load one quote at a time) and config (a limit that fits).
# break_crash_loop.py — simulate an out-of-memory crash loop (stdlib only).
# The app loads the whole table into memory at startup. The limit is small.
MEMORY_LIMIT_MB = 10 # stands in for the real 256Mi limit
BYTES_PER_MB = 1024 * 1024
loaded = [] # the app keeps every quote in memory
chunk = b"x" * BYTES_PER_MB # one megabyte of quotes, again and again
used_mb = 0
restarts = 0
while used_mb < MEMORY_LIMIT_MB + 5:
loaded.append(chunk)
used_mb += 1
if used_mb >= MEMORY_LIMIT_MB:
restarts += 1
print(f"Memory {used_mb}MB >= limit {MEMORY_LIMIT_MB}MB -> OOMKilled, pod restarts (restart #{restarts})")
loaded = [] # a fresh pod starts again, and loads the table again...
used_mb = 0
if restarts >= 3:
break
print()
print("Real incident: pod runs ~30s, memory climbs to 256Mi, OOMKilled, restarts. 20 restarts in 10 minutes.")
print("Fix: load one quote on demand, raise the limit to 512Mi, alert at 80% memory.")
Try it yourself. Run the script above. Then change MEMORY_LIMIT_MB to 50 and run again — how many restarts do you see now, and why?
Check yourself.
Out Of Memory Killed — Kubernetes killed the pod because it used more memory than its limit allowed.
Code: load one quote at a time instead of the whole table. Config: raise the memory limit to 512Mi and add an alert at 80% memory.
What it is. Azure SRE Agent is an AI agent that helps investigate live production incidents. SRE stands for Site Reliability Engineering — the job of keeping a live service reliable. When an incident starts, the agent reads three kinds of evidence: logs (the written record of what the service did), metrics (numbers like latency, error rate, CPU, and memory), and traces (the path one request took through the system). It compares what it sees with what is normal, forms a hypothesis, checks it against more evidence, and reports a root cause with the evidence that supports it. It does not change anything by itself — it investigates, and a human approves the fix.
Why it matters. An incident at 2 a.m. is the worst time to think from scratch. The SRE Agent does the fast, boring part — reading thousands of log lines and charts — so the human can do the judgement part.
# What the SRE Agent reads, for the quote service.
EVIDENCE = {
"logs": "Every request logged: method, path, status, time. Errors logged with the full message.",
"metrics": "Request count, p95 latency, error rate, pod restarts, CPU, memory.",
"traces": "The path of one request: ingress -> service -> pod -> database.",
"config": "The Deployment, Service, and ConfigMap as applied in the cluster.",
}
for kind, meaning in EVIDENCE.items():
print(f"{kind:10s} {meaning}")
print()
print("The agent's job: compare this evidence with normal, find what changed,")
print("form a hypothesis, check it, and report the root cause with evidence.")
print("The agent never changes production by itself. A human approves the fix.")
Try it yourself. Write down the four kinds of evidence the SRE Agent reads, and one example of each for the quote service.
Check yourself.
Site Reliability Engineering — the job of keeping a live service reliable.
No. It investigates and reports the root cause with evidence. A human approves the fix.
What it is. You do not just say 'fix it' to the SRE Agent. You give it a clear prompt with the symptom, the time window, the service name, and what you already know — and a runbook to follow. A good SRE prompt has five parts: the symptom, the service and environment, the time window, the evidence to read first, and the question to answer. The runbook is the written procedure: check pod status, check restarts, read recent logs, compare metrics with the baseline, form a hypothesis, verify it, then report the root cause with evidence and a proposed fix. The examples below are the reusable prompt and runbook templates you walk away with.
Why it matters. A vague prompt gives a vague investigation. A prompt with the symptom, the window, and the evidence to read first gives an investigation you can trust — and check.
# SRE Agent prompt template (copy and reuse for your own services).
PROMPT = """Investigate an incident on the quote-service in production (AKS).
Symptom: the service is down and the pods keep restarting.
Time window: the last 30 minutes.
Service: quote-service, namespace production, 3 replicas.
Read first, in this order:
1. kubectl get pods — pod status and restart counts.
2. kubectl logs deployment/quote-service --tail=200 — recent errors.
3. Pod restarts and memory/CPU metrics vs the last 7 days.
4. The ConfigMap quote-config and the Deployment, as applied.
Answer these questions:
- What is the root cause, with the exact evidence for it?
- What changed recently (deploy, config, traffic)?
- What is the proposed fix, and what should we check after applying it?
Do not change anything. Report only.
"""
print(PROMPT)
print("Runbook steps: 1) pods, 2) logs, 3) metrics vs baseline,")
print("4) config as applied, 5) hypothesis, 6) verify, 7) report root cause + fix.")
Try it yourself. Copy the prompt template above and fill it in for the slow-dependency scenario: change the symptom, and change step 2 to read the database latency.
Check yourself.
Symptom, service and environment, time window, evidence to read first, and the question to answer.
So the agent investigates only. Changing production without human approval is how a small incident becomes a big one.
What it is. Root cause analysis means following the evidence until you reach the one change that explains everything. For the bad-config incident, the chain is: pods restarting → health check failing → app listening on 8080 → ConfigMap says PORT=8080 → someone changed the ConfigMap without changing the Service. The root cause is the config change, not the restarts. The last step matters as much as the first: connect the finding back to the repository. Open a GitHub issue with the symptom, the evidence, and the root cause, link it to the fix pull request, and add a rule to the Copilot harness so the same mistake is caught before deploy next time. The code below is the incident record: the shape of the issue you open.
Why it matters. An incident you do not write down will happen again. The issue, the fix, and the new harness rule are what turn one incident into a permanently safer system.
# Incident record — the shape of the GitHub issue you open.
INCIDENT = {
"title": "[incident] quote-service down: pods restarting after config change",
"symptom": "Service down, pods restarting 12 times in 10 minutes.",
"evidence": [
"kubectl get pods: CrashLoopBackOff, restarts climbing.",
"kubectl logs: 'could not bind to port 8080'.",
"ConfigMap quote-config: PORT=8080; Service expects 8000.",
],
"root_cause": "ConfigMap changed PORT to 8080 without changing the Service. Health check on 8000 fails, Kubernetes restarts the pod, loop repeats.",
"fix": "Set PORT back to 8000. Add a harness rule: the Copilot harness must check that ConfigMap PORT matches the Service targetPort before deploy.",
"follow_up": "Add a deploy-time check: fail the pipeline if PORT and targetPort differ.",
}
print("TITLE:", INCIDENT["title"])
print("SYMPTOM:", INCIDENT["symptom"])
print("EVIDENCE:")
for e in INCIDENT["evidence"]:
print(" -", e)
print("ROOT CAUSE:", INCIDENT["root_cause"])
print("FIX:", INCIDENT["fix"])
print("FOLLOW-UP:", INCIDENT["follow_up"])
Try it yourself. Write an incident record like the one above for the crash-loop scenario, in your own words: symptom, two pieces of evidence, root cause, fix.
Check yourself.
The ConfigMap was changed to PORT=8080 without changing the Service, so the health check on port 8000 fails and Kubernetes restarts the pod forever.
So the finding is written down, linked to the fix, and turned into a harness rule — so the same mistake cannot happen again silently.
What it is. Remediation is the fix, done properly: change the code or config, commit it, let the pipeline test it, roll it out one pod at a time, and verify the service is healthy. For the bad-config incident: set PORT back to 8000 in the ConfigMap, commit, apply the manifest, watch the rollout, and check that pod restarts are zero and /health answers. Verification is not optional: watch the metrics for 10 minutes — restarts, latency, error rate — and only then close the incident. The script below is the verification checklist, run as code.
Why it matters. A fix you do not verify is a guess. The incident is only closed when the numbers say the service is healthy, not when you feel it should be.
# Verification checklist, run as code after a fix.
# Fill in the real numbers from kubectl and your metrics after redeploying.
checks = [
("Pods running (3/3 Ready)", True),
("Pod restarts in the last 10 minutes: 0", True),
("/health answers OK in under 0.1s", True),
("/quote answers in under 1s", True),
("Error rate back to 0%", True),
("Fix committed and linked to the incident issue", True),
]
print("VERIFICATION AFTER REDEPLOY")
all_ok = True
for name, ok in checks:
print(("PASS " if ok else "FAIL ") + name)
all_ok = all_ok and ok
print()
print("Incident closed:", "YES - all checks pass" if all_ok else "NO - keep investigating")
print("Commands: kubectl rollout status deployment/quote-service")
print(" kubectl get pods")
print(" curl http://localhost:8080/health")
Try it yourself. Copy the checklist above and run through it after your next deploy — local or on AKS — and tick each line with a real result.
Check yourself.
Fixing the problem properly: change the code or config, commit it, roll it out safely, and verify the service is healthy.
When the numbers say the service is healthy — restarts zero, latency normal, error rate zero — not when you feel it should be fixed.
What it is. Not everything should be automated. The rule is simple: automate what is safe, reversible, and well understood; keep a human in charge of what is risky, irreversible, or new. Auto-scale pods when traffic rises? Yes — safe and reversible. Restart a failed pod? Yes — Kubernetes already does it. Roll back a bad deploy automatically when health checks fail? Yes — if the rollback is tested. Change production config, delete data, or deploy a fix during an incident? No — a human approves those. The table below is the decision guide you walk away with.
Why it matters. Automation without judgement is how a small mistake becomes a big outage. The human approval boundary is the line between 'the system fixes itself' and 'a person decides'. Draw it on purpose, and write it down.
# Automate vs human approval — the decision table, as data.
DECISIONS = [
("Restart a failed pod", "AUTOMATE", "Safe, reversible, Kubernetes already does it."),
("Scale pods up when traffic rises", "AUTOMATE", "Safe and reversible; set a max so cost stays bounded."),
("Roll back a deploy when health checks fail", "AUTOMATE", "Only if the rollback itself is tested."),
("Apply a config change to production", "HUMAN", "Config mistakes are the most common incidents."),
("Deploy a fix during an incident", "HUMAN", "A human checks the fix and owns the risk."),
("Delete data or drop a database", "HUMAN", "Irreversible. Always a human, always a second pair of eyes."),
("A brand-new failure the agent has never seen", "HUMAN", "New means unknown. A human investigates first."),
]
for action, who, reason in DECISIONS:
print(f"{who:9s} {action}")
print(f"{'':9s} Why: {reason}")
print()
print("Rule: automate what is safe, reversible, and well understood.")
print("Keep a human in charge of what is risky, irreversible, or new.")
Try it yourself. Pick one task from your own work and decide: automate, or human approval? Write down your reason, using the rule above.
Check yourself.
Risky, irreversible, or new things: production config changes, deploying a fix during an incident, deleting data, and any failure the agent has never seen before.
Because restarting a failed pod is safe and reversible, and Kubernetes already does it.
What it is. The replay guide is the written set of steps to run the whole loop again, on your own or with your team: build the service from the spec, ship it, break it with one of the three scenarios, diagnose it with the SRE prompts, fix it, and verify. The repo you walk away with contains the full lab, the infrastructure, the application code, the Copilot harness, the break scenarios, and this replay guide — so anyone can repeat the workshop without you in the room. Each replay should use a different break scenario, and each replay should end with one new harness rule or one new runbook step.
Why it matters. A workshop you can only do once is a demo. A workshop with a replay guide is a practice your team can repeat until the loop is second nature.
# The replay guide, as a runnable checklist.
REPLAY = [
"1. BUILD - clone the repo, read the spec, build the service with the Copilot harness",
"2. TEST - run the tests: python3 -m unittest test_app -v (all must pass)",
"3. SHIP - build the container, deploy to kind (local) or AKS",
"4. BREAK - pick ONE scenario: bad config, slow dependency, or crash loop",
"5. DIAGNOSE - use the SRE Agent prompt template; find the root cause with evidence",
"6. REMEDIATE - fix it, redeploy, verify with the checklist",
"7. RECORD - open an issue, link the fix, add one harness rule or runbook step",
]
for step in REPLAY:
print(step)
print()
print("Replay rule: a different break scenario each time, and one new rule each time.")
Try it yourself. Run the replay guide above for the bad-config scenario on your local kind cluster, and write down the one new rule you would add.
Check yourself.
The full lab, infrastructure, application code, Copilot harness, break scenarios, and replay guide.
One new harness rule or one new runbook step, so the system gets safer every time.
What it is. Cost: AKS costs money every hour the cluster runs, even when it does nothing. Keep the cluster small (few nodes, small machines), use it only while you practise, and delete it when you finish — az aks delete stops the bill. The container registry and log storage also cost a little, so clean up old images and set log retention. Governance: every change to production goes through the repo — manifests reviewed like code, deploys from the pipeline, never kubectl apply from a laptop at 2 a.m. without a record. Human approval boundaries: the table from the automate-vs-human lesson, written into the repo as a file, so the boundary is a decision, not a habit.
Why it matters. Cost and governance are not boring extras. They are what make the difference between a workshop and a system your company can actually run.
# Cost and governance checklist, as data.
GUIDANCE = [
("COST", "AKS bills every hour the cluster exists. Delete it when you finish: az aks delete."),
("COST", "Keep the cluster small: 2 small nodes are enough for this lab."),
("COST", "Clean up old container images and set log retention (for example 30 days)."),
("GOVERNANCE", "Every production change goes through the repo and a review. No silent kubectl apply."),
("GOVERNANCE", "Manifests are versioned. You can always say exactly what is running, and roll it back."),
("GOVERNANCE", "The governance gate runs in the pipeline: tests pass, harness rules pass, then deploy."),
("APPROVAL", "Write the automate-vs-human table into the repo as APPROVALS.md, so the boundary is a decision."),
]
for area, rule in GUIDANCE:
print(f"[{area:11s}] {rule}")
Try it yourself. Write down your own cost rule for AKS: when will you create the cluster, and when will you delete it?
Check yourself.
Delete the cluster when you finish — az aks delete. AKS bills every hour the cluster exists.
Every production change goes through the repo and a review, manifests are versioned, and the pipeline checks tests and harness rules before deploying.
What it is. This is the checklist you walk away with for adapting the workflow to your own services. Work through it service by service: write a one-page spec; add a Copilot harness with your team's rules; add tests, logging, and a /health endpoint; containerize; write the manifests; deploy locally first; write three break scenarios for your service; write the SRE prompts for it; decide the automate-vs-human table; and run the replay. A service is ready when every box is ticked.
Why it matters. Do not try to do all your services at once. Do one, properly, with the checklist. The second one is faster, because the harness, the templates, and the runbooks already exist.
# Checklist for adapting the workflow to your own services.
CHECKLIST = [
"Write a one-page spec: goal, endpoints, rules, operational requirements.",
"Add a Copilot harness: .github/copilot-instructions.md with your team rules.",
"Add tests for every endpoint, logging on every request, and a /health endpoint.",
"Containerize: Dockerfile, build it, run it locally, check /health.",
"Write the Kubernetes manifests: Deployment, Service, ConfigMap, health checks, limits.",
"Deploy locally first (kind or minikube), then to AKS.",
"Write three break scenarios for your service (config, slow dependency, resource limit).",
"Write the SRE Agent prompts and runbook for your service.",
"Decide the automate-vs-human table and write it into the repo.",
"Run the replay: break it, diagnose it, fix it, record it.",
]
for i, item in enumerate(CHECKLIST, 1):
print(f"[ ] {i:2d}. {item}")
print()
print("A service is ready when every box is ticked.")
Try it yourself. Pick one service you own and tick the boxes you already have. The unticked boxes are your next steps.
Check yourself.
Ten — from the one-page spec to running the replay.
Because the harness, templates, and runbooks from the first service make the second one faster.
What it is. Capstone, extra practice: take a service of your own — or the quote service with a new feature — and run the full Build, Ship, Break, Diagnose, Remediate loop end to end, by yourself. Add a feature to the spec (for example, a /random endpoint that returns a random quote), implement it with the Copilot harness, test it, containerize it, deploy it locally, break it with a scenario you invent, diagnose it with the SRE prompts, fix it, verify it, and record it as an issue with a new harness rule. When you finish, you have done the whole workshop on a service that matters to you.
Why it matters. This is where the workshop becomes yours. The quote service taught you the loop. Your own service is where you prove you can run it.
# Capstone plan — the full loop, end to end, on your own service.
CAPSTONE = [
"BUILD: add a /random endpoint to the spec, implement it with the harness, test it.",
"SHIP: containerize, deploy locally (kind), check /health and /random.",
"BREAK: invent your own break scenario (hint: a wrong environment variable).",
"DIAGNOSE: use the SRE prompt template. Find the root cause with evidence.",
"REMEDIATE: fix it, redeploy, verify with the checklist, close the incident.",
"RECORD: open an issue, link the fix, add one new harness rule.",
]
for step in CAPSTONE:
print(step)
print()
print("Done when: the service is healthy, the incident is recorded, and the harness has one new rule.")
Try it yourself. Start the capstone: add the /random endpoint to the spec in your own words, then implement it in app.py.
Check yourself.
A /random endpoint that returns a random quote.
A healthy service, a recorded incident, and one new rule in the Copilot harness.
What it is. Before you call the workshop done, tick every box: the quote service runs locally and in Kubernetes; the tests pass; the container builds; the manifests deploy; you have run all three break scenarios and found each root cause; you have an incident issue with evidence and a fix for at least one scenario; the Copilot harness has a rule you added yourself; the automate-vs-human table is written down; and the AKS cluster is deleted if you created one, so the bill stops.
Why it matters. A checklist at the end is how you know you actually did the workshop, instead of just reading about it.
# Final checklist — tick every box before you call the workshop done.
FINAL = [
"The quote service runs locally (python3 app.py) and in a container (docker run).",
"All tests pass: python3 -m unittest test_app -v.",
"The manifests deploy to kind/minikube (and to AKS, if you tried it).",
"You ran all three break scenarios and found each root cause.",
"At least one incident issue exists, with evidence and a linked fix.",
"The Copilot harness has a rule you added yourself.",
"The automate-vs-human table is written down (APPROVALS.md).",
"The AKS cluster is deleted if you created one (az aks delete).",
]
for i, item in enumerate(FINAL, 1):
print(f"[ ] {i}. {item}")
Try it yourself. Tick the boxes you can already tick, and write the rest down as your next steps.
Check yourself.
An incident issue with evidence and a linked fix for at least one scenario.
Delete it when you finish, so the bill stops.
What it is. Next steps: first, run the replay guide with a different break scenario. Then, go deeper on the cloud side with the Local-First AI Agents, Ready for the Cloud workshop in this repo — it covers the same journey from local to production in more depth, with ADK, LiteLLM, and observability. After that, try the Financial agent workshop, which runs a full agent system in production on bare Debian with FastAPI, systemd, and nginx. And keep the habit: every incident you meet at work, run through the loop — write it down, find the root cause, fix it, and add a rule so it cannot happen again silently.
Why it matters. The workshop ends, but the loop does not. The next incident is your next practice session.
# Your next steps, in order.
NEXT = [
"1. Replay the loop with a different break scenario.",
"2. Local-First AI Agents, Ready for the Cloud — deeper local-to-production journey.",
"3. Financial agent workshop — a full agent system in production (FastAPI, systemd, nginx).",
"4. At work: every incident goes through the loop — record it, fix it, add a rule.",
]
for step in NEXT:
print(step)
Try it yourself. Open the Local-First AI Agents, Ready for the Cloud workshop page in the repo and read its first section.
Check yourself.
Local-First AI Agents, Ready for the Cloud, in this repo.
The Financial agent workshop.
Try the closed loop here. Pick a break scenario and watch a simulated SRE Agent work through it: symptom, logs and metrics, root cause, fix, redeploy, healthy.
Pick a scenario and press the button.
© 2026 Oswaldo Bentti. All rights reserved.
All courses · Ozbit News · quantbite.io · www.linkedin.com/in/ozbit