docs/hosting/databricks.md
import reflex as rx
This guide walks you through deploying a Reflex web application on Databricks using the Apps platform.
Create a new file called app.yaml directly in Databricks (not in GitHub):
command: [
"reflex",
"run",
"--env",
"prod",
"--backend-port",
"$DATABRICKS_APP_PORT"
]
env:
- name: "HOME"
value: "/tmp/reflex"
- name: "REFLEX_ACCESS_TOKEN"
value: "your-token-here"
- name: "DATABRICKS_WAREHOUSE_ID"
value: "your-sql-warehouse-id"
- name: "DATABRICKS_CATALOG"
value: "your-catalog-name"
- name: "DATABRICKS_SCHEMA"
value: "your-schema-name"
- name: "REFLEX_SHOW_BUILT_WITH_REFLEX"
value: 0
your-token-here in the configurationDATABRICKS_WAREHOUSE_ID with your SQL warehouse IDDATABRICKS_CATALOG with your target catalog nameDATABRICKS_SCHEMA with your target schema nameUpdate your Reflex application for Databricks compatibility:
import reflex as rx
import reflex_enterprise as rxe
rxe.Config(app_name="app", use_single_port=True)
Modify your main application file where you define rx.App:
import reflex_enterprise as rxe
app = rxe.App(
# your app configuration
)
# Also add `reflex-enterprise` and `asgiproxy` to your `requirements.txt` file.
If you are using the samples Catalog then you can skip the permissions section.
To deploy updates from your GitHub repository:
rx.table.root(
rx.table.header(
rx.table.row(
rx.table.column_header_cell("Environment Variable"),
rx.table.column_header_cell("Description"),
rx.table.column_header_cell("Example"),
),
),
rx.table.body(
rx.table.row(
rx.table.cell(rx.code("HOME")),
rx.table.cell("Application home directory"),
rx.table.cell(rx.code("/tmp/reflex")),
),
rx.table.row(
rx.table.cell(rx.code("REFLEX_ACCESS_TOKEN")),
rx.table.cell("Authentication for Reflex Cloud"),
rx.table.cell(rx.code("rx_token_...")),
),
rx.table.row(
rx.table.cell(rx.code("DATABRICKS_WAREHOUSE_ID")),
rx.table.cell("SQL warehouse identifier"),
rx.table.cell("Auto-assigned"),
),
rx.table.row(
rx.table.cell(rx.code("DATABRICKS_CATALOG")),
rx.table.cell("Target catalog name"),
rx.table.cell(rx.code("main")),
),
rx.table.row(
rx.table.cell(rx.code("DATABRICKS_SCHEMA")),
rx.table.cell("Target schema name"),
rx.table.cell(rx.code("default")),
),
rx.table.row(
rx.table.cell(rx.code("REFLEX_SHOW_BUILT_WITH_REFLEX")),
rx.table.cell("Show Reflex branding (Enterprise only)"),
rx.table.cell([rx.code("0"), " or ", rx.code("1")]),
),
),
variant="surface",
margin_y="1em",
)
$DATABRICKS_APP_PORT and single-port configuration