Deploy a Databricks app
After you create and develop your Databricks app, you’re ready to deploy it. Deployment makes the app accessible in the Databricks workspace and runs it using the settings defined in your project files.
If you create an app from a template, Databricks deploys it automatically when you first create it. However, you can still re-deploy it later after you make changes. See Create a Databricks app from a template.
Prepare for deployment
Before you deploy your app, verify that your project includes the necessary components:
- Main script - Your entry point file, such as
app.py
. - Optional
app.yaml
file - If your app requires a custom command or environment variables, include anapp.yaml
file to configure execution. See Configure Databricks app execution withapp.yaml
. - Dependencies - Make sure all dependencies are available. This could include:
- A
requirements.txt
file. - Any local Python modules your app depends on. See Manage dependencies for a Databricks app.
- A
- Secrets or environment values - If you use the
env
section inapp.yaml
, verify that the referenced secrets or external sources are correctly configured and accessible. See Add resources to a Databricks app.
In addition, make sure the app service principal has access to the source code folder.
Deploy the app
- Databricks UI
- Databricks CLI
To deploy an app from the Databricks UI:
- Upload the app files to your Databricks workspace. For instructions, see Import a file.
- Click
Compute in the sidebar.
- Go to the Apps tab and click the link to your app in the Name column.
- Click Deploy and select the folder in your workspace where you uploaded the app files.
- Click Select, then Deploy.
- Review the configuration and click Deploy.
To deploy an app using the CLI:
-
Open a terminal, navigate to the directory that contains your app files and run the
sync
command to upload them to Databricks. Replace the path with the workspace location where you want to upload the files.Bashdatabricks sync --watch . /Workspace/Users/my-email@org.com/my-app
To exclude specific files or directories, add them to a
.gitignore
file in your local app directory. -
To view the files in your workspace, click
Workspace in the sidebar and go to the directory created for your app.
-
To deploy the app, run the following command in a terminal. Replace the source code path with the workspace location of your app files.
Bashdatabricks apps deploy my-app-name \
--source-code-path /Workspace/Users/my-email@org.com/my-app
Once deployed, Databricks starts your app based on the defined command
in your app.yaml
file or defaults to running python app.py
.
Post-deployment behavior
After deployment, the app runs in a managed environment. To view the deployment status, go to the overview page for the app.
To view the deployed app's output, click the app link.
Go to the Logs tab for debugging and runtime monitoring. See View logs for your Databricks app.
Update or redeploy the app
You might want to update or re-deploy your app if you made changes to the source code, updated the app.yaml
file, or need to deploy from a different source code path. Re-deploying applies your latest updates without needing to recreate the app from scratch.
To make changes to a deployed app:
- Update your app code or
app.yaml
configuration. - Return to the Apps page in the Databricks workspace.
- Select your app and choose Deploy again. If the source code path changed, click the arrow next to Deploy and select Deploy using different source code path
Troubleshoot deployment issues
If your app fails to deploy or doesn’t run as expected, try the following troubleshooting steps:
- Check logs - View error messages or runtime output in the logs panel.
- Validate
app.yaml
- Make sure the syntax is correct and supported settings are used. - Verify secrets and environment variables - Make sure all references in the
env
section resolve properly. - Confirm dependencies - Make sure all required packages are included or installed.