Define environment variables in a Databricks app
Databricks automatically sets several environment variables in the app runtime environment. These variables provide essential information about the app and workspace and are accessible to all Databricks apps by default.
Default environment variables
The following default environment variables are available to every app:
Variable | Description |
---|---|
| The name of the running app. |
| The unique ID for the Databricks workspace the app belongs to. |
| The URL of the Databricks workspace to which the app belongs. |
| The network port the app should listen on. |
| The client ID for the Databricks service principal assigned to the app. |
| The OAuth secret for the Databricks service principal assigned to the app. |
Define additional environment variables
If your app requires additional environment variables, define them explicitly in the app.yaml configuration file in the env
section. Each variable requires a name and a value. For example:
env:
- name: 'API_KEY'
value: '12345abcde67890'
- name: 'LOG_LEVEL'
value: 'DEBUG'
- name: 'FEATURE_FLAG_NEW_UI'
value: 'true'
Default environment variables for Streamlit
If you use the Streamlit framework, the Databricks Apps environment pre-configures several Streamlit-specific environment variables:
Variable | Description |
---|---|
| The server address for use by Streamlit. This value is set to 0.0.0.0 and must not be overridden. |
| The port for use by Streamlit. This value is set to DATABRICKS_APP_PORT and must not be overridden. |
| Because the Databricks Apps reverse proxy protects against Cross-Site Request Forgery (XSRF), this is set to |
| Because the Databricks Apps reverse proxy protects against Cross-Origin Resource Sharing (CORS), This is set to |
| This is set to |
| This is set to |