---
title: Add resources to a Databricks app
description: This article covers adding resources and managing secrets for your Databricks app.
canonical_url: https://docs.databricks.com/aws/en/dev-tools/databricks-apps/resources
---

# <a id="resource-dependencies" />Add resources to a Databricks app

Your Databricks apps can integrate with various Databricks platform features, such as Databricks SQL for querying data, Lakeflow Jobs for data ingestion and processing, Model Serving to access AI models, and Databricks secrets for managing sensitive information. In the context of apps, these platform features are referred to as *resources*.

## <a id="why-use-resources" />Why use resources?

To keep apps portable and secure, avoid hardcoding resource IDs. For example, instead of embedding a fixed SQL warehouse ID in your app code, configure the SQL warehouse as a resource through the Databricks Apps UI.

Using Databricks Apps resources instead of direct API calls has several benefits:

* Automatically manages credentials and permissions, which eliminates manual token handling in your code.
* Handles resource paths, endpoints, and connection details automatically.
* Provides secure, managed access instead of requiring self-managed credentials for direct API calls.
* Keeps apps portable between environments without code changes.

## <a id="supported-resources" />Supported resource types

The following table lists all resource types that you can add to your Databricks app:

| Resource type                                                                                                        | Description                                                                         | Default resource key                                                 | Available permissions                                                          |
| -------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | -------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| [Databricks app](https://docs.databricks.com/aws/en/dev-tools/databricks-apps/apps-resource.md)                      | App-to-app communication and invocation                                             | `app`                                                                | <ul><li>Can use</li></ul>                                                      |
| [Genie Agent](https://docs.databricks.com/aws/en/dev-tools/databricks-apps/genie.md)                                 | AI-powered analytics interface for natural language queries                         | `genie-space`                                                        | <ul><li>Can view</li><li>Can run</li><li>Can edit</li><li>Can manage</li></ul> |
| [Lakebase database](https://docs.databricks.com/aws/en/dev-tools/databricks-apps/lakebase.md)                        | PostgreSQL database for data storage and querying                                   | `postgres` (Lakebase Autoscaling), `database` (Lakebase Provisioned) | <ul><li>Can connect and create</li></ul>                                       |
| [Lakeflow job](https://docs.databricks.com/aws/en/dev-tools/databricks-apps/lakeflow.md)                             | Data ingestion and processing workflows                                             | `job`                                                                | <ul><li>Can view</li><li>Can manage and run</li><li>Can manage</li></ul>       |
| [MLflow experiments](https://docs.databricks.com/aws/en/dev-tools/databricks-apps/mlflow.md)                         | AI application observability, evaluation, and experiment tracking                   | `experiment`                                                         | <ul><li>Can read</li><li>Can edit</li><li>Can manage</li></ul>                 |
| [Model serving endpoint (Model)](https://docs.databricks.com/aws/en/dev-tools/databricks-apps/model-serving.md)      | Machine learning model deployment for inference requests                            | `model`                                                              | <ul><li>Can view</li><li>Can query</li><li>Can manage</li></ul>                |
| [Unity Gateway model service (Model)](https://docs.databricks.com/aws/en/dev-tools/databricks-apps/unity-gateway.md) | Governed AI model inference through Unity Gateway with Unity Catalog access control | `model`                                                              | <ul><li>Can execute</li></ul>                                                  |
| [Secret](https://docs.databricks.com/aws/en/dev-tools/databricks-apps/secrets.md)                                    | Secure storage for sensitive values like API keys and tokens                        | `secret`                                                             | <ul><li>Can read</li><li>Can write</li><li>Can manage</li></ul>                |
| [SQL warehouse](https://docs.databricks.com/aws/en/dev-tools/databricks-apps/sql-warehouse.md)                       | Compute resources for running SQL queries                                           | `sql-warehouse`                                                      | <ul><li>Can use</li><li>Can manage</li></ul>                                   |
| [Unity Catalog connection](https://docs.databricks.com/aws/en/dev-tools/databricks-apps/connections.md)              | Managed connections to external data sources                                        | `connection`                                                         | <ul><li>Use Connection</li></ul>                                               |
| [Unity Catalog table](https://docs.databricks.com/aws/en/dev-tools/databricks-apps/tables.md)                        | Structured data storage with fine-grained access control                            | `table`                                                              | <ul><li>Can select</li><li>Can select and modify</li></ul>                     |
| [User-defined function](https://docs.databricks.com/aws/en/dev-tools/databricks-apps/functions.md)                   | Registered SQL and Python functions in Unity Catalog                                | `function`                                                           | <ul><li>Can execute</li></ul>                                                  |
| [Unity Catalog volume](https://docs.databricks.com/aws/en/dev-tools/databricks-apps/uc-volumes.md)                   | File storage in Unity Catalog for app artifacts and data                            | `volume`                                                             | <ul><li>Can read</li><li>Can read and write</li></ul>                          |
| [AI Search index](https://docs.databricks.com/aws/en/dev-tools/databricks-apps/vector-search.md)                     | Semantic search and similarity-based retrieval from vector embeddings               | `vector-search-index`                                                | <ul><li>Can select</li></ul>                                                   |

## <a id="resources-prereqs" />Prerequisites

To add a resource to an app, the following conditions must be met:

* The resource must exist.
* The user adding the resource must have the `Can manage` permission on the resource and the app.

Apps run with least privilege and rely on existing resources within the Databricks platform. When deployed, the app’s service principal accesses these resources and must have the necessary permissions, such as table-level access for SQL queries or read access to secrets. See [Configure authorization in a Databricks app](https://docs.databricks.com/aws/en/dev-tools/databricks-apps/auth.md).

## <a id="configure-resources" />Configure resources for your app

Resources allow your app to securely connect to services that it depends on, without hardcoding sensitive or environment-specific values.

Add resources in the Databricks Apps UI when you create or edit an app, or with the Databricks CLI.

### UI

1. In the **App resources** section when you create an app, or in **Settings** > **Resources** when you edit an app, click **+ Add resource**.
2. Select the resource type you want to add.
3. Set the permissions for the app service principal on the resource.
4. Assign a key to the resource, and reference that key in your `app.yaml` file.

![Adding a SQL warehouse as an app resource in the UI](https://docs.databricks.com/aws/en/images/apps/add-resource-warehouse.png)

### CLI

To add resources with the Databricks CLI, run `databricks apps create-update` with a `resources` array. Each resource has a `name`, which is the key you reference in `app.yaml`, and one resource-type field.

The update replaces the app's full list of resources. Include every resource the app needs, not only the one you're adding. To see the current list, run `databricks apps get my-app`.

```bash
databricks apps create-update my-app --json '{
  "update_mask": "resources",
  "app": {
    "resources": [
      {
        "name": "sql-warehouse",
        "sql_warehouse": {"id": "<warehouse-id>", "permission": "CAN_USE"}
      },
      {
        "name": "table",
        "uc_securable": {
          "securable_full_name": "main.sales.orders",
          "securable_type": "TABLE",
          "permission": "SELECT"
        }
      }
    ]
  }
}'
```

The following table lists the field and permission values for each resource type:

| Resource type                            | Field                                                       | Required properties              | Permission values                                      |
| ---------------------------------------- | ----------------------------------------------------------- | -------------------------------- | ------------------------------------------------------ |
| SQL warehouse                            | `sql_warehouse`                                             | `id`                             | `CAN_USE`, `CAN_MANAGE`, `IS_OWNER`                    |
| Secret                                   | `secret`                                                    | `scope`, `key`                   | `READ`, `WRITE`, `MANAGE`                              |
| Job                                      | `job`                                                       | `id`                             | `CAN_VIEW`, `CAN_MANAGE_RUN`, `CAN_MANAGE`, `IS_OWNER` |
| Serving endpoint                         | `serving_endpoint`                                          | `name`                           | `CAN_VIEW`, `CAN_QUERY`, `CAN_MANAGE`                  |
| Unity Catalog volume                     | `uc_securable` with `securable_type` set to `VOLUME`        | `securable_full_name`            | `READ_VOLUME`, `WRITE_VOLUME`                          |
| Unity Catalog table                      | `uc_securable` with `securable_type` set to `TABLE`         | `securable_full_name`            | `SELECT`, `MODIFY`                                     |
| Unity Catalog function                   | `uc_securable` with `securable_type` set to `FUNCTION`      | `securable_full_name`            | `EXECUTE`                                              |
| Unity Catalog connection                 | `uc_securable` with `securable_type` set to `CONNECTION`    | `securable_full_name`            | `USE_CONNECTION`                                       |
| Genie Agent                              | `genie_space`                                               | `name`, `space_id`               | `CAN_VIEW`, `CAN_RUN`, `CAN_EDIT`, `CAN_MANAGE`        |
| MLflow experiment                        | `experiment`                                                | `experiment_id`                  | `CAN_READ`, `CAN_EDIT`, `CAN_MANAGE`                   |
| Databricks app                           | `app`                                                       | `name`                           | `CAN_USE`                                              |
| Unity Gateway model service              | `uc_securable` with `securable_type` set to `MODEL_SERVICE` | `securable_full_name`            | `EXECUTE`                                              |
| AI Search index                          | `uc_securable` with `securable_type` set to `TABLE`         | `securable_full_name`            | `SELECT`                                               |
| Lakebase database (Lakebase Autoscaling) | `postgres`                                                  | `branch`, `database`             | `CAN_CONNECT_AND_CREATE`                               |
| Lakebase database (Lakebase Provisioned) | `database`                                                  | `instance_name`, `database_name` | `CAN_CONNECT_AND_CREATE`                               |

> [!NOTE]
>
> If you define your app using Declarative Automation Bundles, you specify resources in YAML as part of your bundle configuration instead of using the UI. See [app.resources](https://docs.databricks.com/aws/en/dev-tools/bundles/resources.md#app-resources).

## <a id="manage-access" />Manage app access to resources

Each app has a dedicated [service principal](https://docs.databricks.com/aws/en/dev-tools/databricks-apps/auth.md#app-authorization). Follow these best practices to manage access securely.

* Use the app's service principal for authentication. Never hardcode personal access tokens (PATs) in your code. Access credentials are automatically injected as environment variables:
  * `DATABRICKS_CLIENT_ID`
  * `DATABRICKS_CLIENT_SECRET`
* Don't share service principal credentials between apps or across users. Each app should use its own dedicated credentials for isolation and security.
* Apply least privilege access. Grant only the minimum required permissions to the app's service principal. For example:
  * Grant `CAN USE` on a SQL warehouse if the app only needs to run queries.
  * Grant `CAN QUERY` on a serving endpoint if the app only sends inference requests.
  * Grant `SELECT` or `MODIFY` on Unity Catalog tables based on the app’s data access needs.

## <a id="next-steps" />Next steps

After you add resources to your app, reference these resources in the `env` section of your app configuration using the `valueFrom` field. For instructions, see [Define environment variables in a Databricks app](https://docs.databricks.com/aws/en/dev-tools/databricks-apps/environment-variables.md). For a reference that shows the value that `valueFrom` resolves to for each resource type, see [`valueFrom` reference](https://docs.databricks.com/aws/en/dev-tools/databricks-apps/environment-variables.md#valuefrom-reference).
