What you will be able to do
- Define an agent's resources in a Declarative Automation Bundle and deploy it per environment with validate, deploy and run
- Add the right Vector Search update step to a pipeline for Triggered, Continuous and Direct Vector Access indexes
- Promote a prompt version from dev to staging to production by reassigning aliases, and roll it back by moving the alias back
- Arrange unit, integration and canary tests so each one catches a different agent failure
Key concept
Parameterize, don't hardcode — The same bundle, agent code and prompt reference are deployed to dev, staging and production. Whatever differs between environments comes from bundle targets, variables or prompt aliases, so promoting a change means moving a pointer or picking a target, not editing code.
1.Deploying an agent as a bundle per environment
A CI/CD pipeline sends every change to an agent through code review and an automated deploy, so a production rollout never depends on one developer's laptop. For an agent on Databricks Apps, once the pipeline is set up, every merge to the main branch deploys and restarts the agent. An agent is more than its Python code, though. It also needs an MLflow experiment, often a Lakebase database for memory, a prompt in the registry and a Vector Search index. A pipeline that ships only the code leaves all of those to be set up by hand.
Declarative Automation Bundles (formerly Databricks Asset Bundles) solve this by declaring code, jobs and infrastructure in one YAML file, databricks.yml, and deploying them as a single unit. Each environment is a target in that file. Databricks recommends separate workspaces for development, staging and production, one repository for code and bundle configuration, trunk-based branching, and versioned artifacts such as Git commit hashes so every deployment can be traced and rolled back. CI authenticates as a service principal, and workload identity federation is the recommended method because it removes the need for stored Databricks secrets.
The deploy job runs the same short sequence for every target:
- Run unit tests on the pull request or on the commit to main.
- Run
databricks bundle validateto catch misconfigurations, such as missing libraries, before anything is deployed. - Run
databricks bundle deploy --target prodto create or update the declared resources. - Run
databricks bundle run <bundle-key> --target prodto start the agent app. The key must match the resource key indatabricks.yml. - Wait for the app to report healthy, then send a smoke-test request.
Two agent-specific failures show up the first time this runs on a fresh CI runner. First, agent templates leave MLFLOW_EXPERIMENT_ID empty in databricks.yml. The quickstart script fills it in on a developer's machine, but a CI runner does not, so bundle deploy fails with a Terraform type error: For input string: "". The fix is to commit the numeric experiment ID. Experiments are scoped to a workspace, so a pipeline that deploys to several workspaces needs a separate experiment in each targets.<env> block, or a bundle variable. Second, the advanced templates declare a Lakebase Postgres resource, which bundle deploy provisions. The app's service principal still needs Postgres-level grants on its memory tables. Those grants are a one-time step, run between the first deploy and the first run. After that, CI redeploys go straight through deploy and then run.
Checkpoint 1 of 6· Put it in order
A CI pipeline deploys an advanced agent template, which declares a Lakebase Postgres resource for memory, to a new production workspace for the first time. Put the steps in order.
- 1.Run databricks bundle validate to catch misconfigurations before anything is deployed
- 2.Run databricks bundle deploy --target prod to create the declared resources, including the Lakebase database
- 3.Run databricks bundle run <bundle-key> --target prod to start the agent app
- 4.Wait for the app to report healthy, then send a canary request to /invocations
- 5.Grant the app's service principal Postgres-level privileges on its memory tables
Validation comes before deployment. The deploy step provisions the Lakebase database, but the service principal still needs Postgres grants before the agent starts. bundle run only signals the agent to start, so the health check and canary request come last. The grant is a one-time step: later CI redeploys go straight from deploy to run.
“Granting these Postgres-level privileges is a one-time setup. Run it locally between the first bundle deploy and bundle run.”Source: docs.databricks.com
2.Updating the Vector Search index in the pipeline
A retriever can only be as current as its index, and a deployment that changes the source table hasn't finished until the index reflects that change. A Delta Sync index follows its source table through the table's change feed, so a pipeline that writes the table depends on Enabling Change Data Feed so a Delta Sync index can follow the table having been done when the table was created. What happens after the write depends on the sync mode, compared in Triggered vs continuous sync. A Continuous index updates by itself when the source changes. A Triggered index waits until someone or something starts a sync, so in CI/CD that sync has to be an explicit pipeline step.
client = AISearchClient()
index = client.get_index(index_name="vector_search_demo.vector_search.en_wiki_index")
index.sync()The same step is available as POST /api/2.0/vector-search/indexes/{index_name}/sync or as the CLI command databricks vector-search-indexes sync-index my-delta-sync-index, which fits a shell step in a workflow file. The CLI rejects any other index type: the index to synchronize must be a Delta Sync index. Infrastructure changes need the sync step too. After a pipeline raises an endpoint's target QPS with update_endpoint(), the indexes have to be synced before the new configuration takes effect.
Two shortcuts are wrong. Deleting and recreating the index on every run replaces a single sync call with a full rebuild. Editing the index's storage directly is also off-limits: a Delta Sync index keeps its data in a Unity Catalog table that you can query, but must not drop or modify. To change the index, change the source table and sync.
A Direct Vector Access index has no source table to follow. When embeddings come from a model outside Databricks, the pipeline computes the vectors and writes them, along with their metadata, into the index itself, using the SDK's index.upsert() or the REST API to insert, update or delete rows. Use this type when the team doesn't want a synced Delta table as the source of truth. In exchange, keeping the index current is entirely the pipeline's job.
databricks vector-search-indexes upsert-data-vector-index my-index '{"vectors": [{"id": "1", "vector": [0.1, 0.2, 0.3], "metadata": {"title": "Document 1"}}]}'| Index setup | What the pipeline does after data changes | Call |
|---|---|---|
| Delta Sync, Continuous | Nothing extra: the index updates when the source table changes | None |
| Delta Sync, Triggered | Writes the source table, then starts a sync | index.sync() or POST /api/2.0/vector-search/indexes/{index_name}/sync |
| Direct Vector Access | Writes vectors and metadata into the index itself | index.upsert() |
Checkpoint 2 of 6· Exam question
A nightly ETL job appends newly ingested documents to a Delta table that backs a Delta Sync Vector Search index. The team wants the index to reflect the new rows within minutes of the ETL job finishing, but does not want a streaming pipeline running continuously between batches. Which CI/CD configuration best satisfies this requirement?
Correct answer: A — Set the index to Triggered sync mode and call the sync trigger through the REST API or SDK as the last task of the ETL job
- A. Triggered mode refreshes a Delta Sync index only when a sync is requested. Calling the sync API as the last ETL task starts the update right after the batch lands, and no compute runs between batches.
- B. Continuous mode keeps a streaming pipeline running at all times to propagate changes within seconds. That freshness is not needed here, and it means a pipeline running between batches, which the team wants to avoid.
- C. Direct Vector Access indexes have no link to a Delta table and do not read its change feed. The client has to upsert vectors and metadata itself, so new rows would never appear in the index unless extra code writes them.
- D. Triggered mode is the right mode, but a fixed hourly cron is not tied to when the ETL job finishes. Rows can wait up to an hour for a sync, which misses the requirement of reflecting new rows within minutes of the job finishing.
Checkpoint 3 of 6· Exam question
A team computes document embeddings using a custom model hosted outside Databricks and wants a CI/CD job to push the newly computed vectors and metadata into a production Vector Search index after every build, without maintaining a synced Delta table as the source of truth. Which approach fits this requirement?
Correct answer: A — Use a Direct Vector Access index and upsert the new vectors and metadata through the Vector Search SDK or REST API in a CI/CD job step
- A. A Direct Vector Access index has no Delta source table. The caller writes vectors and metadata straight to the index through the SDK or REST API. That matches a CI/CD job that produces embeddings outside Databricks and needs no Delta table as the source of truth.
- B. A Delta Sync index supports self-managed embeddings, but it always reads from a source Delta table, and a sync only picks up changes made to that table. Using it here means maintaining the synced Delta table as the source of truth, which the team wants to avoid. Triggering the sync from the CI/CD job does not remove that dependency.
- C. Dropping and recreating a Direct Vector Access index takes the production index offline and leaves it empty until the full reload finishes. Queries during that window fail or return incomplete results. Upserting the new vectors updates the live index in place and avoids this.
- D. Continuous sync keeps the index aligned with a source Delta table, so the CI/CD job would have to write the vectors and metadata into that table first. That makes a Delta table the source of truth, which the team does not want to maintain. A Direct Vector Access index accepts writes directly.
3.Promoting and rolling back prompts with aliases
A prompt moves through environments differently from code. A deployed agent loads its prompt through an alias such as @production, as taught in Prompt aliases and loading by alias. Promotion then needs no build and no redeploy: the pipeline reads which version the source environment's alias points to and points the target environment's alias at the same version. This works because the two objects behave differently. Prompt versions are immutable snapshots with auto-incrementing numbers, while aliases are mutable pointers. What staging tested is exactly what production will load.
def promote_prompt(name: str, from_env: str, to_env: str):
"""Promote prompt from one environment to another."""
# Get current version in source environment
source = mlflow.genai.load_prompt(f"prompts:/{name}@{from_env}")
# Point target environment to same version
mlflow.genai.set_prompt_alias(
name=name,
alias=to_env,
version=source.version
)
print(f"Promoted {name} v{source.version} from {from_env} to {to_env}")In a pipeline, this becomes two gated calls. When work merges, dev is pointed at the new version. When staging is approved, promote_prompt(name, "dev", "staging") runs. When production is approved, promote_prompt(name, "staging", "production") runs. Re-registering the same text produces a new version number, and copying prompt text into an environment variable or a file bypasses the registry. Both add something untested and lose the link to what was validated.
Rollback works the same way in reverse: point the alias back at an earlier version. To make that a one-line call, record the outgoing version under its own alias before moving production. If the new prompt misbehaves, set production to the version held by production-previous. Every version is still there, so nothing has to be restored. Even delete_prompt_alias() removes only the pointer, never the versions.
def safe_production_update(name: str, new_version: int):
"""Update production with rollback capability."""
try:
# Save current production
current = mlflow.genai.load_prompt(f"prompts:/{name}@production")
mlflow.genai.set_prompt_alias(name, "production-previous", current.version)
except:
pass # No current production
# Update production
mlflow.genai.set_prompt_alias(name, "production", new_version)Two details matter when this runs in production. First, keep the prompt name and alias in environment variables, so each environment's deployment chooses its alias without a code change. Second, an agent deployed as a Custom Agent cannot reach the prompt registry through its default setup. It must use manual authentication, overriding the security environment variables so the Databricks client connects to the registry with credentials you configure. That override has a side effect: it disables automatic passthrough, the mechanism that otherwise supplies credentials for the other resources the agent depends on. With passthrough off, those resources no longer get credentials automatically, so a resource that worked before the override can start failing authentication until you configure access for it as well. For traceability, call mlflow.set_active_model() with a name built from the Git commit before loading the prompt. MLflow then records which prompt version each application version used, which is the first thing to check when a rollback is being considered.
Checkpoint 4 of 6· Check yourself
Right after the pipeline moved the production alias from version 4 to version 5, answer quality drops. Before the move, the pipeline saved version 4 under the production-previous alias. What is the quickest correct rollback?
Versions never change, and aliases are pointers that can be moved. Pointing production back at version 4, which production-previous still holds, restores exactly the version that was validated. You don't need to re-register, redeploy or restore anything. Re-registering the text creates a new, untested version number. Deleting the alias only removes the pointer and gives the agent no version to fall back to.
“Aliases: Mutable pointers to specific versions”Source: docs.databricks.com
Checkpoint 5 of 6· Exam question
A team stores its agent's system prompt in the MLflow Prompt Registry and loads it in production code using the URI prompts:/catalog.schema.answer_prompt@production. After validating a new prompt version in staging, they need to promote it to production as part of their CI/CD pipeline without changing or redeploying the application code. Which action accomplishes this?
Correct answer: A — Call set_prompt_alias() in the CI/CD job to move the production alias onto the validated prompt version number
- A. Prompt versions are immutable, and an alias is a movable pointer to one of them. Pointing
productionat the validated version means the existingprompts:/catalog.schema.answer_prompt@productionURI resolves to the new text. The application code is never edited or redeployed. - B. Registering the text creates a new immutable version, but the application still loads through the
@productionalias, which keeps pointing at the old version. Pinning the new version number in the load URI means editing and redeploying the application code. That is exactly what this promotion has to avoid. - C. Moving the
stagingalias is a valid registry operation, but production code resolves theproductionalias. Thestagingpointer is never read by the production application, so production keeps serving the previous prompt version. The promotion does not happen. - D. The application loads its prompt through a registry URI and does not read an environment variable. Using the variable would need an application code change, and the endpoint update would also be a new configuration rollout. It also bypasses the registry's versions and aliases, so the promotion is no longer tracked there.
4.Testing agent components from unit to canary
An agent fails in layers. A tool might parse a date wrongly, the retriever might return the wrong chunks, the assembled agent might call the right tools in the wrong order, or the deployed app might never finish booting. A single end-to-end test catches all of these but can't tell you which one happened. So the pipeline tests each layer separately, cheapest first, in the environment where that layer can actually be checked.
| Layer | What it checks | Where it runs | Mechanism |
|---|---|---|---|
| Unit | A single tool function or retriever helper, called directly with fixed inputs | CI runner, on every pull request | pytest |
| Configuration | Bundle definition: resources, libraries, targets | CI runner, before deploy | databricks bundle validate |
| Integration | The full agent working against real endpoints, indexes and prompts | Staging workspace after bundle deploy | Evaluation dataset compared against the previous version |
| Canary | The deployed app answers a real request after it boots | Target environment after bundle run | POST to /invocations with an OAuth token |
Unit tests treat each tool and retriever as ordinary business logic and test it with pytest, without starting the agent. They are fast enough to run on every pull request. Integration testing follows the standard ML flow: code is deployed to a staging workspace and tested there, and only vetted artifacts are promoted. For an agent, the integration check is an evaluation run over a fixed dataset, so the new version is measured against the old one and a fix in one area can't quietly cause a regression in another. Building and scoring those datasets is covered in Evaluating agents with MLflow scoring and tracing.
The canary step exists because databricks bundle run reports success too early. It returns as soon as the runner tells the agent to start, but the agent process can still crash while booting, for example on a missing Postgres grant. So after the health check passes, the workflow sends a real request to /invocations and fails the job on anything other than HTTP 200. The token must be the workspace OAuth token from databricks auth token, because Databricks Apps reject every other token type. A canary that uses a personal access token fails even when the agent is healthy.
- name: Smoke test invocations
env:
APP_NAME: my-agent
run: |
APP_URL=$(databricks apps get "$APP_NAME" --output json | jq -r '.url')
TOKEN=$(databricks auth token | jq -r '.access_token')
STATUS=$(curl -sS -o /tmp/canary.json -w "%{http_code}" \
-X POST "$APP_URL/invocations" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"input": [{"role": "user", "content": "ping"}], "stream": false}')
if [ "$STATUS" != "200" ]; then
echo "Smoke test failed with status $STATUS:" >&2
cat /tmp/canary.json >&2
exit 1
fi
echo "Smoke test passed."A failed canary should start a rollback, not just send an alert. Databricks recommends tracking deployment success rates and automating rollback when a deployment fails. Each kind of change already has a cheap way back: redeploy the bundle from the previous commit for code, or point the alias back for a prompt. Prompt aliases also allow a gentler canary. Because aliases are mutable references, the registry supports A/B tests and gradual rollouts in which a new prompt version serves part of the traffic under its own alias before production is moved.
Checkpoint 6 of 6· Check yourself
In a deploy job, databricks bundle run --target prod exits with success. Moments later the agent process crashes while booting because its service principal has no Postgres grant on the memory tables. Which pipeline step is meant to catch this failure?
bundle run returns once the agent has been told to start, so a crash during boot happens after that step has already reported success. Only the canary request to the deployed app's /invocations endpoint, sent in the target environment after the health check, confirms that the agent actually answers. Unit tests, validate and the staging evaluation all run before or apart from that production boot.
“databricks bundle run returns as soon as the runner signals the agent to start, but the agent process may still fail during boot.”Source: docs.databricks.com
Sources
(8)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“Once the pipeline is configured, every merge to your main branch deploys and restarts your agent on Databricks Apps.”
↩︎ Deploying an agent as a bundle per environment“If experiment_id is empty, databricks bundle deploy fails with a Terraform type error”
↩︎ Deploying an agent as a bundle per environment“Granting these Postgres-level privileges is a one-time setup.”
↩︎ Deploying an agent as a bundle per environment“add the following smoke-test step to deploy.yml that posts a canary request to /invocations”
↩︎ Testing agent components from unit to canary“Databricks Apps only accept OAuth tokens for invocation.”
↩︎ Testing agent components from unit to canary“databricks bundle run returns as soon as the runner signals the agent to start, but the agent process may still fail during boot.”
↩︎ Exam trap 4“Granting these Postgres-level privileges is a one-time setup. Run it locally between the first bundle deploy and bundle run.”
↩︎ Checkpoint“databricks bundle run returns as soon as the runner signals the agent to start, but the agent process may still fail during boot.”
↩︎ Checkpoint - 2.
“Use Declarative Automation Bundles to deploy code, jobs, and infrastructure as a single unit.”
↩︎ Deploying an agent as a bundle per environment“Declarative Automation Bundles (formerly known as Databricks Asset Bundles)”
↩︎ Deploying an agent as a bundle per environment“Maintain separate workspaces for development, staging, and production.”
↩︎ Deploying an agent as a bundle per environment“Databricks recommends workload identity federation for CI/CD authentication.”
↩︎ Deploying an agent as a bundle per environment“Implement unit tests for business logic using libraries, such as pytest for Python and ScalaTest for Scala.”
↩︎ Testing agent components from unit to canary“Data scientists submit ML code, which runs unit tests and deploys to a staging workspace for integration testing.”
↩︎ Testing agent components from unit to canary“Implement automated rollback mechanisms for failed deployments.”
↩︎ Testing agent components from unit to canary“Parameterize instead of hardcoding environment-specific settings, such as cluster size and secrets.”
↩︎ Key concept - 3.
“Indexes created with Continuous sync mode automatically update when the source table or view changes.”
↩︎ Updating the Vector Search index in the pipeline“You can use the Python SDK or the REST API to insert, update, or delete data from a Direct Vector Access Index.”
↩︎ Updating the Vector Search index in the pipeline“After updating target QPS, sync your indexes to apply the new configuration.”
↩︎ Updating the Vector Search index in the pipeline“If you are using Triggered sync mode, you can start the sync using the UI, the Python SDK, or the REST API.”
↩︎ Exam trap 1“you should not drop or modify the table, as it is not intended to be manually updated.”
↩︎ Exam trap 2“If you are using Triggered sync mode, you can start the sync using the UI, the Python SDK, or the REST API.”
↩︎ Prediction - 4.https://docs.databricks.com/aws/en/dev-tools/cli/reference/vector-search-indexes-commandsOfficial docs
“Name of the vector index to synchronize. Must be a Delta Sync Index.”
↩︎ Updating the Vector Search index in the pipeline - 5.https://docs.databricks.com/aws/en/mlflow3/genai/prompt-version-mgmt/prompt-registry/use-prompts-in-deployed-appsOfficial docs
“Promote prompts between environments by reassigning aliases:”
↩︎ Promoting and rolling back prompts with aliases“To access the prompt registry from an agent deployed using Custom Agents, you must use manual authentication”
↩︎ Promoting and rolling back prompts with aliases“Overriding these security environment variables disables automatic passthrough for other resources your agent depends on.”
↩︎ Promoting and rolling back prompts with aliases“reassign the production alias to point to a newer version without changing or redeploying your application code.”
↩︎ Exam trap 3“reassign the production alias to point to a newer version without changing or redeploying your application code.”
↩︎ Prediction - 6.
“Versions: Immutable snapshots with auto-incrementing numbers”
↩︎ Promoting and rolling back prompts with aliases“Remove aliases (versions remain)”
↩︎ Promoting and rolling back prompts with aliases“for A/B testing and gradual rollouts”
↩︎ Testing agent components from unit to canary“Aliases: Mutable pointers to specific versions”
↩︎ Checkpoint - 7.https://docs.databricks.com/aws/en/mlflow3/genai/prompt-version-mgmt/prompt-registry/track-prompts-app-versionsOfficial docs
“MLflow automatically creates lineage between your prompt versions and application versions.”
↩︎ Promoting and rolling back prompts with aliases - 8.
“verify that improvements work without introducing regressions”
↩︎ Testing agent components from unit to canary