Skip to main content

Configure Databricks app execution with app.yaml

The app.yaml file in a Databricks app defines how your app is executed. By default, Databricks runs your app using the command python app.py. If your app requires a different entry point or environment-specific configuration, you can include an optional app.yaml file in your project to customize the execution behavior.

You can use the .yaml or .yml file extension. This file must be located in the root of your project directory.

Supported settings

The app.yaml file supports the following settings.

Setting

Type

Description

command

sequence

An optional set of arguments to run your app. Use this setting when you require a custom command to run your app. The default values are [python, app.py].

Because the command is not run in a shell, environment variables defined outside the app configuration are not passed to your app. If your app requires additional parameters to run, use the env structure.

This setting is optional.

env

list

Databricks automatically sets several default environment variables in the app runtime environment. This top-level key defines an optional list of additional environment variables to pass to your app. Each variable can use a hardcoded value or reference an external source, such as a secret or database entry.

The valid items in the list are:

  • name: The name of the environment variable.
  • One of:

This setting is optional.

Example app.yaml for a Streamlit app

The following app.yaml file shows how to configure a Streamlit app. It uses a custom command to start the app with streamlit run, and it sets environment variables for the SQL warehouse ID and a usage tracking flag.

YAML
command: ['streamlit', 'run', 'app.py']
env:
- name: 'DATABRICKS_WAREHOUSE_ID'
value: 'quoz2bvjy8bl7skl'
- name: 'STREAMLIT_GATHER_USAGE_STATS'
value: 'false'

Use a setup like this if your app depends on a specific compute resource, such as a SQL warehouse, or requires certain environment variables to control runtime behavior.

Example app.yaml for a Flask app

This example shows how to configure a Flask app using the Gunicorn server. The command setting specifies the Gunicorn startup parameters, and the env section sets the path to a Unity Catalog volume as an environment variable.

YAML
command:
- gunicorn
- app:app
- -w
- 4
env:
- name: 'VOLUME_URI'
value: '/Volumes/catalog-name/schema-name/dir-name'

Use this approach when your app needs a production-ready WSGI server like Gunicorn and when it depends on data stored in a Unity Catalog volume or another environment-specific path.