Analysing and serving · Chapter 15
Databricks Apps: what they are, cost, and when to use them
Reviewed by TechFabric engineers. How we write this guide →
Databricks Apps hosts a Python or Node.js web application inside your Databricks workspace, on serverless compute, behind the workspace's own OAuth sign-in. Each app gets its own service principal, can act on behalf of the signed-in user so Unity Catalog row filters and column masks apply to what it shows, and declares the warehouses, Genie Agents, Lakebase databases and endpoints it uses as resources instead of hard-coded IDs. It bills per hour while running, from 0.5 DBU an hour for the default size.
The use is the screen a governed platform keeps getting asked for: a review queue, an approval form, a small tool that reads three tables and writes one. Built on another host, the governance usually stops at its door. The decisions that matter are which identity the app runs as, which scopes it asks for, and what it costs while nobody uses it. Facts below are as of 22 October 2026.
The short version
Databricks Apps runs an ordinary web app (Streamlit, Dash, Gradio, Flask or FastAPI in Python; React, Angular, Svelte or Express in Node) without you standing up a server, a login page or a secret store. The reason we'd use it is identity: the app can act as the person clicking, so the access rules you already wrote in Unity Catalog reach the screen without being rebuilt in the application.
What runs, and where #
The system environment (updated 11 September 2026) is Ubuntu 22.04 LTS with Python 3.11 in a dedicated virtual environment and Node.js 22.16. Python dependencies come from requirements.txt (or uv, which can select a different Python version); Node apps bring their own package.json, since no Node libraries are pre-installed. Every app gets these variables:
| Variable | What it holds |
|---|---|
DATABRICKS_HOST |
The workspace URL |
DATABRICKS_APP_PORT |
The port your server must listen on |
DATABRICKS_CLIENT_ID, DATABRICKS_CLIENT_SECRET |
The app service principal's OAuth credentials |
DATABRICKS_APP_NAME, DATABRICKS_WORKSPACE_ID |
Identity of the app and its workspace |
Listen on 0.0.0.0 and the port from DATABRICKS_APP_PORT. For Streamlit and Uvicorn the runtime also sets STREAMLIT_SERVER_PORT and UVICORN_PORT to match, which is why a bare streamlit run app.py works. Since 14 October 2026 workspace admins can set default Python and npm package repositories that every app inherits, which matters if your network blocks public PyPI.
When we'd reach for it, and when we wouldn't #
We'd use Databricks Apps when the people using the tool already have Databricks identities and the tool's job is to read or change governed data. An approvals queue over a gold table, a data-quality triage screen, a search box over an AI Search index, a question box over a Genie Agent: each would otherwise need its own deployment, its own login and its own copy of the access rules.
We wouldn't use it for three shapes of application.
- Anonymous public traffic. Every request is authenticated against the workspace. A marketing site or a portal for your customers' users, who have no Databricks login, is the wrong shape; for customer-facing reporting, Multi-tenant reporting covers embedding instead.
- Spiky, mostly idle load. Apps bill for provisioned capacity while running, whether or not anyone is using them. A tool opened twice a week costs the same per hour as one open all day.
- A team with a deployment platform it likes, working single sign-on and no governance drift. There's nothing to fix, and we'd spend the effort where the estate still guesses who can see what.
A working example is Prove It, which Ivan Vydrin, a Databricks engineer at TechFabric, built for Databricks' Genie-Powered App Challenge, where Databricks named it a winner on 10 September 2026. It's a Streamlit app on Databricks Apps that uses the Genie Conversation API to turn a claim into SQL, shows that SQL before the answer, and reads four Unity Catalog tables through a SQL warehouse (the write-up). Its app.yaml declares the Genie Agent as a resource (valueFrom: genie-space) and runs as the app's own service principal, with "Can run" on the space and SELECT on the schema, which suits a public demo where every visitor should see the same data.
How does authentication work in Databricks Apps? #
This is the decision people get wrong, and we'd settle it in design review before anyone writes a screen.
Every app gets a dedicated service principal, created with the app, unique to it and deleted with it. Databricks injects its credentials as DATABRICKS_CLIENT_ID and DATABRICKS_CLIENT_SECRET, and the Databricks SDK picks them up without configuration. When the app acts as that principal, every user shares one set of grants, so a row filter keyed on the current user sees the app, not the person.
User authorization, usually called on-behalf-of-user, does the opposite. Databricks forwards the signed-in user's token in the x-forwarded-access-token header, and queries made with it run under that user's Unity Catalog permissions, row filters and column masks included (app authorization, updated 9 October 2026).
In a Streamlit app (1.37 or later, for st.context.headers) the user's token is one header read, and the SQL connector takes it in place of the app's credentials:
import os
import streamlit as st
from databricks import sql
from databricks.sdk.core import Config
cfg = Config() # host and the app's own credentials come from the environment
user_token = st.context.headers.get("x-forwarded-access-token")
with sql.connect(
server_hostname=cfg.host,
http_path=f"/sql/1.0/warehouses/{os.environ['WAREHOUSE_ID']}", # from app.yaml, below
access_token=user_token, # run as the person, so their filters and masks apply
) as conn:
with conn.cursor() as cursor:
cursor.execute("SELECT * FROM sales.gold.open_orders LIMIT 1000")
df = cursor.fetchall_arrow().to_pandas()
st.dataframe(df)In Flask or FastAPI it's the same header on the incoming request. Mature apps use both identities, and we'd draw the line by asking whose action it is. Reading what a person is entitled to runs as the user. Writing an audit record, calling an outside service or reading shared configuration runs as the app, because those actions belong to the application. The reverse mistake is the one to catch in review: a write-back done with the service principal's grants lets every user change rows only some of them can see, so writes that touch governed rows go on the user's token too.
Scopes are the second permission check #
An on-behalf-of app declares the API scopes it needs, and Databricks blocks anything outside them even when the user has permission. With none selected the app gets only iam.access-control:read and iam.current-user:read, which reach no data and no compute, so a forgotten scope fails closed. The API scopes are sql, genie, model-serving, vector-search (AI Search), files, postgres, ai-gateway, ai-functions, apps and sql:restricted-query, plus SDK scopes such as catalog.tables that accept a :read modifier.
Users consent once per app and set of scopes, the first time they open it, and can revoke that later. The control we'd rely on sits with workspace admins: under Settings, Development, Apps, "Restrict OAuth scopes for apps to selected values" limits what any app may request (the CLI setting is allowedAppsUserApiScopes), and an empty list turns user authorization off. Tightening that list bites at the next deploy, since an app that still asks for a removed scope can't be started, deployed or updated, so we'd schedule it with app owners.
Resources, not hard-coded IDs #
An app declares the platform objects it uses as resources (updated 2 October 2026). Each one grants the app's service principal a named permission and hands the app an identifier through valueFrom in app.yaml:
| Resource | Default key | Permissions you can grant | valueFrom resolves to |
|---|---|---|---|
| SQL warehouse | sql-warehouse |
Can use, Can manage | Warehouse ID |
| Genie Agent | genie-space |
Can view, Can run, Can edit, Can manage | Space ID |
| Lakebase database | postgres (Autoscaling), database (Provisioned) |
Can connect and create | Endpoint path, or host |
| Model serving endpoint | model |
Can view, Can query, Can manage | Endpoint name |
| Unity Catalog table | table |
Select, Modify | Full table name |
| Unity Catalog volume | volume |
Can read, Can read and write | Volume path |
| Secret | secret |
Can read, Can write, Can manage | The decrypted value |
| AI Search index | vector-search-index |
Can select | Index full name |
Jobs, MLflow experiments, Unity Catalog connections, functions, Unity Gateway model services and other apps can be declared the same way. The key in valueFrom is the resource key you gave it in the app's configuration:
command: ["streamlit", "run", "app.py"]
env:
- name: WAREHOUSE_ID
valueFrom: sql-warehouse
- name: GENIE_SPACE_ID
valueFrom: genie-spaceDeclared resources move with the app between dev and prod workspaces, the grants are visible in one place, and removing the app removes the access.
Connecting an app to Lakebase #
When the app needs to write, as opposed to read analytics, the database we'd put under it is Lakebase. Add a Lakebase database as a resource and Databricks creates a Postgres role named after the app's service principal client ID, grants it CONNECT and CREATE on the database, and sets PGHOST, PGPORT, PGDATABASE, PGUSER, PGSSLMODE and PGAPPNAME for the first database resource (Lakebase resources, updated 9 October 2026). There's no password variable, because the password is a database credential minted from the service principal's identity and valid for an hour. A pool that asks for a fresh one on each new connection handles that:
# requirements.txt: flask, psycopg[binary,pool], databricks-sdk>=0.81.0
import os
import psycopg
from psycopg_pool import ConnectionPool
from databricks.sdk import WorkspaceClient
w = WorkspaceClient()
ENDPOINT = os.environ["ENDPOINT_NAME"] # projects/<project>/branches/<branch>/endpoints/<endpoint>
class OAuthConnection(psycopg.Connection):
@classmethod
def connect(cls, conninfo="", **kwargs):
kwargs["password"] = w.postgres.generate_database_credential(endpoint=ENDPOINT).token
return super().connect(conninfo, **kwargs)
pool = ConnectionPool(
conninfo=(
f"dbname={os.environ['PGDATABASE']} user={os.environ['PGUSER']} "
f"host={os.environ['PGHOST']} port={os.environ.get('PGPORT', '5432')} "
f"sslmode={os.environ.get('PGSSLMODE', 'require')}"
),
connection_class=OAuthConnection,
min_size=1,
max_size=10,
open=True,
)Map ENDPOINT_NAME from the resource with valueFrom: postgres, which resolves to the endpoint path for Lakebase Autoscaling. That's the pattern in Databricks' Apps and Lakebase tutorial (updated 6 October 2026). One warning from the docs worth repeating: don't change a database resource to postgres in an existing app, because the new type creates a new role and the app can lose access to the tables the old role owned.
We built an application on Lakebase live at the first Gilbert Databricks User Group session on 18 September 2026; that was the database tier, not a Databricks Apps deployment, and the Lakebase chapter has its numbers.
Deploying #
From a local folder, sync to the workspace and deploy (Databricks CLI; Git-based creation needs 1.14.0 or later):
databricks apps create approvals-queue
databricks sync --watch . /Workspace/Users/you@example.com/approvals-queue
databricks apps deploy approvals-queue --source-code-path /Workspace/Users/you@example.com/approvals-queueOr deploy from a branch of a GitHub or Azure DevOps repository; with automatic deployments on, Databricks registers a webhook so each push redeploys (deploy, updated 23 September 2026):
databricks apps create approvals-queue --git-url https://github.com/your-org/approvals-queue --git-provider gitHub
databricks apps deploy approvals-queue --git-branch mainLinking a repository doesn't turn on redeploy-on-push by itself: enable "Auto deploy on push events" and set a branch to watch, in the Configure Git step when you create the app or later from the app's settings (automatic Git deployments). The CLI docs don't show a flag for it. Tags don't work for automatic deployment, the repository must be private, and the app's service principal needs a Git credential for it. For an app that lives alongside jobs and pipelines, we'd define it in a Declarative Automation Bundle and deploy it with databricks bundle deploy, as CI/CD and environments describes.
What it costs #
Apps bill per hour of compute while running, based on the size you provision, not on traffic. From the compute size page (updated 25 September 2026):
| Size | CPU | Memory | DBU per hour | A 720-hour month left running |
|---|---|---|---|---|
| Medium, the default | up to 2 vCPUs | 6 GB | 0.5 | 360 DBUs |
| Large | up to 4 vCPUs | 12 GB | 1 | 720 DBUs |
| XLarge | up to 12 vCPUs | 48 GB | 3 | 2,160 DBUs |
At the $0.75 list price per DBU that What it actually costs uses, a Medium app left on all month is $270, and the same app run eight hours a day on working days is about $60. Use your contract rate, and remember the warehouse, Lakebase compute or serving endpoint the app calls bills for its own work. Horizontal scaling went GA on 29 September 2026: an app can run 1 to 5 instances behind one URL, with up to 20 scaled apps per workspace, and "compute cost scales linearly with the number of instances" (horizontal scaling). Session affinity is best effort, so anything a user's session needs goes in Lakebase or a table, not in process memory.
The habit we'd build in from day one is stopping apps nobody opened this week, and sizing up only when the app itself (not the warehouse behind it) is the slow part. A size change keeps the app on the old size until the update finishes, so resizing isn't an outage.
What's popular