Skip to content

Commit 0e0202c

Browse files
committed
Add Azure Web Apps deployment guidance to README
1 parent c36b2fb commit 0e0202c

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,68 @@ For platform-specific guides, see:
547547
[Deploying to Fly.io](https://explainerdashboard.readthedocs.io/en/latest/deployment.html#deploying-to-fly-io)
548548
and
549549
[Deploying to Hugging Face Spaces](https://explainerdashboard.readthedocs.io/en/latest/deployment.html#deploying-to-hugging-face-spaces).
550+
and
551+
[Deploying to Azure Web Apps](#deploying-to-azure-web-apps).
552+
553+
### Deploying to Azure Web Apps
554+
555+
If your app gets stuck on the dashboard `Loading...` screen on Azure, the most common
556+
issue is that the dashboard HTML is returned, but Dash endpoints such as
557+
`/_dash-layout`, `/_dash-dependencies`, or `/_dash-component-suites/*` are not mounted
558+
on the same Flask server and base path.
559+
560+
Use a single WSGI app (`app = db.flask_server()`) and run it with `gunicorn`.
561+
Also avoid re-building the model/explainer inside a Flask request handler.
562+
563+
**dashboard.py**:
564+
```python
565+
import os
566+
from explainerdashboard import ClassifierExplainer, ExplainerDashboard
567+
568+
# Build/load these once at startup:
569+
# model = ...
570+
# X_test = ...
571+
# y_test = ...
572+
573+
explainer = ClassifierExplainer(model, X_test, y_test)
574+
575+
# If your app is mounted under a subpath, e.g. "/dashboard/",
576+
# set APP_BASE_PATH=/dashboard/ in Azure App Settings.
577+
base_path = os.getenv("APP_BASE_PATH", "/")
578+
if not base_path.startswith("/"):
579+
base_path = "/" + base_path
580+
if not base_path.endswith("/"):
581+
base_path = base_path + "/"
582+
583+
db = ExplainerDashboard(
584+
explainer,
585+
url_base_pathname=base_path,
586+
routes_pathname_prefix=base_path,
587+
requests_pathname_prefix=base_path,
588+
title="Model Explainer",
589+
)
590+
591+
app = db.flask_server()
592+
```
593+
594+
**requirements.txt** should include at least:
595+
```txt
596+
explainerdashboard
597+
gunicorn
598+
```
599+
600+
Set your Azure Web App startup command to:
601+
602+
```bash
603+
gunicorn --bind=0.0.0.0:${PORT:-8000} dashboard:app
604+
```
605+
606+
Troubleshooting checklist:
607+
608+
1. Open browser dev tools and check network requests to `/_dash-layout` and `/_dash-dependencies`.
609+
2. If those requests return `404`, fix your base path prefixes (or set `APP_BASE_PATH=/`).
610+
3. If initial page load is very slow, make sure model training and data loading are not done per request.
611+
4. Check App Service logs for worker timeouts and increase plan/resources if needed.
550612

551613
It can be helpful to store your `explainer` and dashboard layout to disk, and
552614
then reload, e.g.:

0 commit comments

Comments
 (0)