Loading...
Loading...
Compare original and translation side by side
agent-*agent-data-analystagent-customer-supportagent-code-helperdatabricks.ymlresources:
apps:
agent_langgraph_long_term_memory:
name: "agent-your-app-name" # Use agent-* prefixagent-*agent-data-analystagent-customer-supportagent-code-helperdatabricks.ymlresources:
apps:
agent_langgraph_long_term_memory:
name: "agent-your-app-name" # Use agent-* prefixundefinedundefined
> **Note:** `bundle deploy` only uploads files and configures resources. `bundle run` is **required** to actually start/restart the app with the new code. If you only run `deploy`, the app will continue running old code!
The resource key `agent_langgraph_long_term_memory` matches the app name in `databricks.yml` under `resources.apps`.
> **注意:** `bundle deploy`仅上传文件并配置资源。必须运行`bundle run`才能使用新代码实际启动/重启应用。如果仅运行`deploy`,应用将继续运行旧代码!
资源键`agent_langgraph_long_term_memory`与`databricks.yml`中`resources.apps`下的应用名称一致。databricks bundle deployError: failed to create app
Failed to create app <app-name>. An app with the same name already exists.databricks bundle deployError: failed to create app
Failed to create app <app-name>. An app with the same name already exists.undefinedundefined
**Step 2:** Update `databricks.yml` to match the existing app's configuration exactly:
```yaml
resources:
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
undefined
**步骤2:** 更新`databricks.yml`使其与现有应用的配置完全匹配:
```yaml
resources:
apps:
agent_langgraph_long_term_memory:
name: "existing-app-name" # Must match exactly
budget_policy_id: "xxx-xxx-xxx" # Copy from step 1 if present重要原因: 现有应用可能包含不在您bundle中的服务器端配置(如)。如果这些配置不匹配,Terraform会提示“Provider produced inconsistent result after apply”错误。绑定前请务必将应用当前配置同步到budget_policy_id。databricks.yml
mode: productionworkspace.root_pathtargets:
prod:
mode: production
workspace:
root_path: /Workspace/Users/${workspace.current_user.userName}/.bundle/${bundle.name}/${bundle.target}重要原因: 生产模式需要明确的根路径,以确保仅部署一份bundle副本。如果未设置此项,部署会失败并提示您设置。workspace.root_path
undefined
> **Note:** If bind fails with "Resource already managed by Terraform", the app is already bound to this bundle. Skip to Step 5 and deploy directly.
**Step 5:** Deploy:
```bash
databricks bundle deploy
databricks bundle run agent_langgraph_long_term_memory
> **注意:** 如果绑定失败并提示“Resource already managed by Terraform”,说明该应用已绑定到此bundle。跳过此步骤直接执行步骤5进行部署。
**步骤5:** 部署:
```bash
databricks bundle deploy
databricks bundle run agent_langgraph_long_term_memorydatabricks apps delete <app-name>
databricks bundle deploydatabricks apps delete <app-name>
databricks bundle deploydatabricks bundle deployment unbind agent_langgraph_long_term_memorydatabricks 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"}
}'重要提示: Databricks Apps仅支持通过OAuth令牌进行查询。您无法使用个人访问令牌(PAT)查询Agent,否则会出现302重定向错误。
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_clientfrom agent_server.utils import get_user_workspace_client
This is useful when you want the agent to access resources with the user's permissions rather than the app's service principal permissions.
See: [OBO authentication documentation](https://docs.databricks.com/aws/en/dev-tools/databricks-apps/auth#retrieve-user-authorization-credentials)
当您希望Agent使用用户权限而非应用服务主体权限访问资源时,此功能非常有用。
参考:[OBO身份验证文档](https://docs.databricks.com/aws/en/dev-tools/databricks-apps/auth#retrieve-user-authorization-credentials)undefinedundefinedundefinedundefinedagent-agent-my-assistantagent-data-analystnamedatabricks.yml# forces replacementagent-agent-my-assistantagent-data-analystdatabricks.ymlname# forces replacementdatabricks auth tokenuv adduv add <package_name>databricks auth tokenuv adduv add <package_name>undefinedundefined| 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 |
| 问题 | 解决方案 |
|---|---|
| 验证错误 | 部署前运行 |
| 运行时权限错误 | 在 |
| Lakebase访问错误 | 若使用记忆功能,请参考lakebase-setup技能配置权限 |
| 应用无法启动 | 运行 |
| 认证令牌过期 | 重新运行 |
| 302重定向错误 | 使用OAuth令牌,而非PAT |
| “Provider produced inconsistent result”错误 | 将应用配置同步到 |
| “should set workspace.root_path”错误 | 为生产目标添加 |
| 部署后应用仍运行旧代码 | 部署后运行 |
| 已部署应用中环境变量为None | 检查app.yaml中的 |