Share via


Add a Databricks app resource to a Databricks app

Add another Databricks app as a resource for your app so it can communicate with other deployed apps. This enables app-to-app interactions, such as calling another app's API or orchestrating workflows across multiple apps.

Add a Databricks app resource

Before you add an app as a resource, review the app resource prerequisites.

  1. When you create or edit an app, navigate to the Configure step.
  2. In the App resources section, click + Add resource.
  3. Select Databricks app as the resource type.
  4. Choose the target app from the available apps in your workspace.
  5. Select the permission level for your app:
    • Can use: Grants the app permission to call and invoke the target app. Corresponds to the CAN USE privilege.
  6. (Optional) Specify a custom resource key, which is how you reference the target app in your app configuration. The default key is app.

When you add a Databricks app resource:

  • Azure Databricks grants your app's service principal the CAN USE permission on the target app.
  • Your app can invoke or call the target app's endpoints.

Environment variables

When you deploy an app with an app resource, Azure Databricks exposes the target app's name (not its URL) through environment variables that you can reference using the valueFrom field. To get the target app's URL, resolve the name using the Azure Databricks SDK.

Example configuration:

env:
  - name: MY_OTHER_APP
    valueFrom: app # Use your custom resource key if different

To resolve the target app's URL in your application:

import os
from databricks.sdk import WorkspaceClient

# Access the target app name from the environment variable
w = WorkspaceClient()
other_app = w.apps.get(name=os.environ["MY_OTHER_APP"])

# Get the target app's URL
url = other_app.url  # e.g. "https://my-other-app-12345.cloud.databricksapps.com"

For more information, see Use environment variables to access resources.

Remove a Databricks app resource

When you remove an app resource, Databricks removes the CAN USE permission from the target app's permission set. Your app can no longer call or invoke the target app. The target app itself remains unchanged and continues to be available for other users and applications that have appropriate permissions.

Best practices

Consider the following when you work with Databricks app resources:

  • Use environment variables and the Azure Databricks SDK to resolve the target app's URL at runtime instead of hardcoding URLs, which keeps your app portable across environments.
  • Implement error handling for cases where the target app is unavailable or returns errors.
  • Monitor the health and availability of target apps, especially if your app depends on them for critical functionality.