import reflex as rx
from pcweb import constants
from pcweb.styles.styles import get_code_style, cell_styleThis guide walks you through deploying a Reflex web application on Databricks using the Apps platform.
- Databricks workspace with Unity Catalog enabled
- GitHub repository containing your Reflex application
- Reflex Enterprise license (for single-port deployment)
- Link GitHub Repository
- Navigate to your Databricks workspace
- Go to your user directory
- Click Create → Git folder
- Paste the URL of your GitHub repository containing the Reflex application
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- Reflex Access Token
- Visit Reflex Cloud Tokens
- Navigate to Account Settings → Tokens
- Create a new token and copy the value
- Replace
your-token-herein the configuration
- Databricks Resources
- Update
DATABRICKS_WAREHOUSE_IDwith your SQL warehouse ID - Update
DATABRICKS_CATALOGwith your target catalog name - Update
DATABRICKS_SCHEMAwith your target schema name
- Update
Update 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.- Navigate to Apps
- Go to Compute → Apps
- Click Create App
- Configure Application
- Select Custom App
- Configure SQL warehouse for your application
If you are using the samples Catalog then you can skip the permissions section.
- Navigate to Catalog → Select your target catalog
- Go to Permissions
- Add the app's service principal user
- Grant the following permissions:
- USE CATALOG
- USE SCHEMA
- Navigate to the specific schema
- Go to Permissions
- Grant the following permissions:
- USE SCHEMA
- EXECUTE
- SELECT
- READ VOLUME (if required)
- Initiate Deployment
- Click Deploy in the Apps interface
- When prompted for the code path, provide your Git folder path or select your repository folder
- Monitor Deployment
- The deployment process will begin automatically
- Monitor logs for any configuration issues
To deploy updates from your GitHub repository:
- Pull Latest Changes
- In the deployment interface, click Deployment Source
- Select main branch
- Click Pull to fetch the latest changes from GitHub
- Redeploy
- Click Deploy again to apply the updates
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",
)- Permission Errors: Verify that all catalog and schema permissions are correctly set
- Port Issues: Ensure you're using
$DATABRICKS_APP_PORTand single-port configuration - Token Issues: Verify your Reflex access token is valid and properly configured
- Deployment Failures: Check the deployment logs for specific error messages
- Single-port deployment requires Reflex Enterprise
- Configuration must be created directly in Databricks, not pushed from GitHub
- Updates require manual pulling from the deployment interface