Add a Lakeflow Jobs resource to a Databricks app
Add Lakeflow Jobs as Databricks Apps resources so your app can trigger, monitor, and manage workflow automation. Lakeflow Jobs provide orchestration for data processing workloads, allowing you to coordinate and run multiple tasks as part of larger workflows within your app.
Add a job resource
Before you can add a job as an app resource, check that you meet the prerequisites.
- In the App resources section when you create or edit an app, click + Add resource. Select Job as the resource type.
- Choose a Lakeflow Job from the available jobs in your workspace.
- Select the appropriate permission level for your app:
- Can view: Grants the app permission to view job details, run history, and status. Use this for monitoring-only applications.
- Can manage run: Grants the app permission to trigger job runs, cancel runs, and view run details.
- Can manage: Grants the app full administrative access to the job, including editing job configuration, tasks, and scheduling.
- (Optional) Specify a custom resource key, which is how you reference the job in your app configuration. The default key is
job
.
When you add a job resource, the app's service principal gains the specified permissions on the selected job, so your app can interact with the workflow based on the granted access level.
Environment variables
When you deploy an app with a Lakeflow Jobs resource, Databricks exposes the job ID through environment variables that you can reference using the valueFrom
field.
For more information, see Use environment variables to access resources.
Remove a job resource
When you remove a Lakeflow Jobs resource from an app, the app's service principal loses access to the job. The job itself remains unchanged and continues to be available for other users and applications that have appropriate permissions.
Any ongoing job runs initiated by the app continue to completion, but the app can no longer trigger new runs or access job details.
Best practices
Consider the following when you work with Lakeflow Jobs resources:
- Grant minimal permissions. Use
Can view
for monitoring applications,Can manage run
for workflow orchestration, andCan manage
only when your app needs to modify job configurations. - Implement proper error handling and retry logic in your app when triggering job runs, as jobs might fail due to resource constraints or data issues.
- Consider the dependencies between your app and the job workflows. Communicate critical job failures to your app users.
- Use job parameters to make your workflows configurable and reusable across different app environments.