Example: Basic Check¶
This example shows a full local loop:
- Run
azure-functions doctor - Read failures and warnings
- Apply fixes
- Re-run until required failures are zero
Scenario¶
Assume this project has common setup gaps:
- missing
requirements.txt - missing
host.json - no active virtual environment
- no
azure-functionsdependency declaration
Step 1: Run the doctor¶
You can also target another folder:
Step 2: Read status correctly¶
Status model:
pass: condition satisfiedwarn: optional rule failedfail: required rule failed
Exit codes:
0when no required failures exist1when at least one required failure exists
Tip
Fix fail items first. Warnings are useful but non-blocking.
Step 3: Use verbose hints¶
Verbose mode prints fix: hints for non-passing checks.
This is the fastest way to map output directly to remediation.
Step 4: Fix required blockers¶
Create requirements.txt¶
Add azure-functions¶
Create minimal host.json¶
Activate a virtual environment¶
Confirm v2 decorator usage¶
import azure.functions as func
app = func.FunctionApp()
@app.route(route="health")
def health(req: func.HttpRequest) -> func.HttpResponse:
return func.HttpResponse("ok")
Step 5: Re-run¶
Desired summary shape:
Doctor summary (to see all details, run azure-functions doctor -v):
0 fails, 2 warnings, 13 passed
Exit code: 0
Warnings can remain while required baseline is clean.
Step 6: Export JSON report¶
The output file includes metadata and results fields.
See JSON Output Contract.
Step 7: Parse key findings in Python¶
import json
from pathlib import Path
def summarize(path: str) -> dict[str, int]:
doc = json.loads(Path(path).read_text(encoding="utf-8"))
counts = {"pass": 0, "warn": 0, "fail": 0}
for section in doc["results"]:
for item in section["items"]:
counts[item["status"]] += 1
return counts
Step 8: Parse key findings in shell¶
If this returns 0, required blockers are resolved.
Optional: Generate SARIF for code scanning tools¶
Optional: Generate JUnit for CI test views¶
What this example validates¶
- Local command execution and output understanding
- Required versus optional semantics
- Repeatable remediation loop
- Artifact generation for automation