Getting Started¶
This guide walks through your first successful run with azure-functions-doctor, explains the output model, and shows common fixes.
1) Prerequisites¶
Before running diagnostics, confirm:
- Python
>=3.10,<3.15 - A local Azure Functions project (Python v2 decorators)
azure-functions-doctorinstalled
If not installed yet, see Installation.
2) Project shape expected by the doctor¶
Azure Functions Doctor validates v2-style projects and expects signals such as:
- Decorator-based app code (for example
@app.route(...)) host.jsonin project rootrequirements.txtin project rootazure-functionslisted in dependencies
Tip
The tool can run on incomplete projects. Failing checks are the normal way it tells you what to fix.
3) First run¶
Run from your project root:
Run against a specific path:
Use verbose mode to show fix hints:
4) Understand output statuses¶
Item-level statuses:
pass: check condition metwarn: optional check failedfail: required check failed
Section-level status:
- Section is
failwhen any required check in that section fails - Optional failures do not fail a section
Exit code semantics:
- Exit
0: no required failures - Exit
1: one or more required failures
This makes CI gating straightforward.
5) Example output walkthrough¶
Representative output shape:
Azure Functions Doctor
Path: /workspace/my-function-app
Python Env
[✓] Python version: Python 3.12.2 (>=3.10)
[✗] requirements.txt: /workspace/my-function-app/requirements.txt not found (fail)
[✗] azure-functions package: Package 'azure-functions' not declared in requirements.txt (fail)
Doctor summary (to see all details, run azure-functions doctor -v):
2 fails, 1 warning, 5 passed
Exit code: 1
How to read this quickly:
- Start at the summary line (
fails,warnings,passed) - Fix all
failitems first (required blockers) - Decide whether to address
warnitems now or later
6) Fix common failures¶
Missing requirements.txt¶
Create the file:
Missing azure-functions declaration¶
Add dependency declaration:
Missing host.json¶
Create a minimal host config:
No active virtual environment¶
Create and activate one:
Programming model v2 check fails¶
Make sure your app uses decorator-based v2 style:
import azure.functions as func
app = func.FunctionApp()
@app.route(route="hello")
def hello(req: func.HttpRequest) -> func.HttpResponse:
return func.HttpResponse("ok")
7) Use profiles intentionally¶
Run all built-in checks (default behavior):
Run only required checks:
Use minimal for strict pass/fail gating and low-noise CI.
See Minimal Profile for exact rule coverage.
8) Machine-readable formats¶
JSON:
SARIF:
JUnit:
Note
The current CLI supports table, json, sarif, and junit output formats.
9) Programmatic usage (Python)¶
Use the public API for custom tooling:
from azure_functions_doctor.api import run_diagnostics
def count_required_failures(path: str) -> int:
failures = 0
for section in run_diagnostics(path=path, profile="full", rules_path=None):
for item in section["items"]:
if item["status"] == "fail":
failures += 1
return failures
See API Reference for detailed module docs.
10) Suggested first-week workflow¶
For teams adopting the doctor:
- Run
azure-functions doctorlocally during development - Fix all required failures before PR creation
- Add CI gate using
--profile minimal --format json - Publish JSON/SARIF/JUnit artifacts for visibility
- Periodically run full profile to capture optional quality signals
11) Where to go next¶
- CLI Usage for complete flag reference
- Rules for per-rule behavior and remediation
- Diagnostics for status mapping details
- JSON Output Contract for parser-safe fields
- Troubleshooting for operational issues