Loading...
Loading...
Deploy agent to Databricks Apps using DAB (Databricks Asset Bundles). Use when: (1) User says 'deploy', 'push to databricks', or 'bundle deploy', (2) 'App already exists' error occurs, (3) Need to bind/unbind existing apps, (4) Debugging deployed apps, (5) Querying deployed app endpoints.
npx skill4agent add databricks/app-templates deployagent-*agent-data-analystagent-customer-supportagent-code-helperdatabricks.ymlresources:
apps:
agent_langgraph_long_term_memory:
name: "agent-your-app-name" # Use agent-* prefix# 1. Validate bundle configuration (catches errors before deploy)
databricks bundle validate
# 2. Deploy the bundle (creates/updates resources, uploads files)
databricks bundle deploy
# 3. Run the app (starts/restarts with uploaded source code) - REQUIRED!
databricks bundle run agent_langgraph_long_term_memoryNote:only uploads files and configures resources.bundle deployis required to actually start/restart the app with the new code. If you only runbundle run, the app will continue running old code!deploy
agent_langgraph_long_term_memorydatabricks.ymlresources.appsdatabricks bundle deployError: failed to create app
Failed to create app <app-name>. An app with the same name already exists.# Get app config including budget_policy_id and other server-side settings
databricks apps get <existing-app-name> --output json | jq '{name, budget_policy_id, description}'databricks.ymlresources:
apps:
agent_langgraph_long_term_memory:
name: "existing-app-name" # Must match exactly
budget_policy_id: "xxx-xxx-xxx" # Copy from step 1 if presentWhy this matters: Existing apps may have server-side configuration (like) that isn't in your bundle. If these don't match, Terraform will fail with "Provider produced inconsistent result after apply". Always sync the app's current config tobudget_policy_idbefore binding.databricks.yml
mode: productionworkspace.root_pathtargets:
prod:
mode: production
workspace:
root_path: /Workspace/Users/${workspace.current_user.userName}/.bundle/${bundle.name}/${bundle.target}Why this matters: Production mode requires an explicit root path to ensure only one copy of the bundle is deployed. Without this, the deploy will fail with a recommendation to set.workspace.root_path
# Check if resource is already managed by this bundle
databricks bundle summary --output json | jq '.resources.apps'
# If the app appears in the summary, skip binding and go to Step 5
# If NOT in summary, bind the resource:
databricks bundle deployment bind agent_langgraph_long_term_memory <existing-app-name> --auto-approveNote: If bind fails with "Resource already managed by Terraform", the app is already bound to this bundle. Skip to Step 5 and deploy directly.
databricks bundle deploy
databricks bundle run agent_langgraph_long_term_memorydatabricks apps delete <app-name>
databricks bundle deploydatabricks bundle deployment unbind agent_langgraph_long_term_memoryIMPORTANT: Databricks Apps are only queryable via OAuth token. You cannot use a Personal Access Token (PAT) to query your agent. Attempting to use a PAT will result in a 302 redirect error.
databricks auth token | jq -r '.access_token'curl -X POST <app-url>/invocations \
-H "Authorization: Bearer <oauth-token>" \
-H "Content-Type: application/json" \
-d '{ "input": [{ "role": "user", "content": "hi" }], "stream": true }'user_idcurl -X POST <app-url>/invocations \
-H "Authorization: Bearer <oauth-token>" \
-H "Content-Type: application/json" \
-d '{
"input": [{"role": "user", "content": "What do you remember about me?"}],
"custom_inputs": {"user_id": "user@example.com"}
}'from agent_server.utils import get_user_workspace_client
# In your agent code
user_client = get_user_workspace_client()
# Use user_client for operations that should run as the user# View logs (follow mode)
databricks apps logs <app-name> --follow
# Check app status
databricks apps get <app-name> --output json | jq '{app_status, compute_status}'
# Get app URL
databricks apps get <app-name> --output json | jq -r '.url'agent-agent-my-assistantagent-data-analystnamedatabricks.yml# forces replacementdatabricks auth tokenuv adduv add <package_name>
# Example: uv add "mlflow-skinny[databricks]"| Issue | Solution |
|---|---|
| Validation errors | Run |
| Permission errors at runtime | Grant resources in |
| Lakebase access errors | See lakebase-setup skill for permissions (if using memory) |
| App not starting | Check |
| Auth token expired | Run |
| 302 redirect error | Use OAuth token, not PAT |
| "Provider produced inconsistent result" | Sync app config to |
| "should set workspace.root_path" | Add |
| App running old code after deploy | Run |
| Env var is None in deployed app | Check |