Databricks Warehouse Auto-Management

Grant Revefi permissions to automatically resize your Databricks SQL warehouses.

This guide is for users who already have Revefi connected to Databricks and want Revefi to auto-manage their SQL warehouses.

🚧

Revefi uses a Databricks job, revefi-automanage-run-managed-by-revefi-do-not-delete, to execute warehouse recommendations. Do not edit or delete it.

Prerequisites

  • You have already set up Revefi with Databricks (completed the initial setup from the main Databricks guide)
  • The revefi catalog from Step 2 of that guide exists
  • A workspace admin can assign entitlements and change warehouse permissions

Step 1: Prepare each workspace (One-time setup)

Do this once for every workspace that has a warehouse you want Revefi to manage. Skip any workspace you have already prepared.

  1. Assign Revefi's service principal to the workspace, with the Workspace access and Databricks SQL access entitlements.
  2. Make sure the workspace can access the revefi catalog. Catalogs are open to all workspaces by default, so most setups need nothing here. If you restricted revefi to specific workspaces, assign this workspace to it.

Step 2: Grant permissions on the warehouses

Grant CAN_MANAGE permission to the service principal on your SQL warehouses. We recommend granting it on all warehouses, so you can start auto-management on any of them from Revefi. Revefi changes a warehouse only after you start auto-management for it in Revefi.

To grant it on one warehouse, open the warehouse's Permissions and give the service principal Can manage.

To grant it on all warehouses, use the script below. It covers one workspace, so run it once in each workspace, with the Databricks CLI pointed at that workspace (for example, --profile <workspace-profile>).

#!/bin/bash

# === CONFIGURATION ===
SERVICE_PRINCIPAL_ID="<service-principal-application-id>"  # e.g., "12345678-aaaa-bbbb-cccc-1234567890ab"

# === Fetch all SQL warehouses ===
echo "Fetching all SQL warehouse IDs..."
WAREHOUSE_IDS=$(databricks warehouses list --output JSON | jq -r '.[].id')

# === Loop through warehouses and assign CAN_MANAGE permission ===
for WAREHOUSE_ID in $WAREHOUSE_IDS; do
  echo "Updating permissions for warehouse_id: $WAREHOUSE_ID"
  databricks permissions update warehouses "$WAREHOUSE_ID" --json '{
    "access_control_list": [
      {
        "service_principal_name": "'$SERVICE_PRINCIPAL_ID'",
        "permission_level": "CAN_MANAGE"
      }
    ]
  }'
  echo "Permissions updated for warehouse $WAREHOUSE_ID"
done

echo "All SQL warehouse permissions updated successfully."

Warehouses created later are not covered. Grant Can manage on them, or run the script again. If a warehouse is in a new workspace, do Step 1 for that workspace first.


Did this page help you?