All Articles
On this page
AI/ML

Deploying DB Agent on Databricks Using LabAgent

F
Fardeen Mazumdar
beCloudReady
December 4, 20266 min read
Deploying DB Agent on Databricks Using LabAgent

Setup work often comes before you can try an AI app. Here is how I deployed a text-to-SQL app on Databricks Free Edition with a repeatable CLI workflow, and how it can help other developers.

Disclosure: I work with beCloudReady, which maintains LabAgent.

1. Why I did this

Before a developer can try an AI app on Databricks, there is setup work: a SQL warehouse, sample data, a model endpoint, a token and the app deployment itself. That is time spent on wiring before you learn anything about the app.

I wanted to understand how an AI-powered database application can be deployed through a repeatable CLI-based workflow, so that the same steps work again for the next person or the next project.

For this I used LabAgent, an open-source CLI for building hands-on cloud and AI labs, to deploy DB Agent, an open-source text-to-SQL application, on Databricks Free Edition. DB Agent lets users question a database in plain English instead of writing SQL.

How this can help you as a developer:

  • Get a working text-to-SQL app to explore without building the deployment yourself
  • Preview the steps with a dry run before anything is created
  • Repeat the same setup with one launch command, once your Databricks CLI is logged in
  • Practise on Databricks Free Edition with sample data that is already there

2. Prerequisites

  • Python 3.9 or later
  • Git
  • Pip
  • Curl and unzip
  • Databricks Free Edition account
  • Linux environment (WSL is used in this walkthrough)

Repositories:

3. Setting up LabAgent

Step 1: Clone the repository

First thing to do is clone the LabAgent repository into your local development environment.

git clone https://github.com/becloudready/labagent.git
cd labagent

Step 2: Create a virtual environment

Create and activate a Python virtual environment to isolate the project's dependencies.

python3 -m venv .venv
source .venv/bin/activate

Step 3: Install LabAgent

pip install labagent

Terminal output of pip install labagent

Make sure to verify the installation by checking the available lab packs.

labagent packs

labagent packs listing the available packs, including db-agent

Among the available packs, locate db-agent, which is responsible for the DB Agent application that we will be deploying on Databricks.

4. Setting up Databricks

Step 1: Create a Databricks account

Create an account using Databricks Free Edition. Once registered, access your Databricks workspace. This is the target environment for our application.

Databricks Free Edition home page

Step 2: Install the Databricks CLI

The Databricks CLI allows LabAgent to communicate with the Databricks workspace and perform the deployment. Install the CLI using:

curl -fsSL https://raw.githubusercontent.com/databricks/setup-cli/main/install.sh | sudo sh

During installation, I encountered two issues relating to directory permissions and a missing unzip directory. Once installed, make sure to verify that the Databricks CLI has been installed successfully.

Installing the Databricks CLI after adding the missing unzip tool

Step 3: Authenticate with Databricks

Authenticate the CLI with your Databricks workspace:

databricks auth login

Complete the authentication process through your default browser. Once authenticated, verify the connection:

databricks auth profiles

The authentication profile should then be displayed.

databricks auth login and auth profiles output

5. Understanding the DB Agent configuration

Before deploying the application, it can be useful to understand which database is being used. The DB Agent deployment pack is located at:

labagent/packs/db_agent/pack.py

By default, DB Agent uses the following configuration:

ParameterConfiguration
Catalogsamples
Datasetbakehouse

DB Agent pack parameters with catalog samples and dataset bakehouse

The samples.bakehouse dataset is an existing sample dataset provided by Databricks. LabAgent simply discovers and connects to this dataset rather than provisioning a new database. To inspect the dataset, navigate to the Catalog section of the Databricks workspace and locate it.

The samples.bakehouse schema in Catalog Explorer

6. Deploying the DB Agent

Step 1: Preview the deployment

LabAgent provides a dry-run option that allows the user to review the deployment workflow before provisioning cloud resources.

labagent launch db-agent --name demo --dry-run

Dry run listing the five launch steps

Step 2: Launch the application

Once LabAgent and Databricks are configured, initiate the deployment using:

labagent launch db-agent --name demo

During the deployment, the first three stages complete successfully before it proceeds to provision the Databricks application. The final stage then verifies the app by asking it a test question.

labagent launch completing all five steps

7. Verifying the deployment on Databricks

Step 1: Check the application status

Open Databricks Apps.

Opening Databricks Apps from the app switcher

You will then see the deployed application there.

db-agent-demo shown as Active in Databricks Apps

Step 2: Access the application

After opening, go to the link that it has been deployed to. The DB Agent interface allows the user to submit natural-language questions against the configured database.

DB Agent answering which product sold the most units, then refusing a delete request

DB Agent counting customers

DB Agent counting franchises in Japan

DB Agent showing revenue per product

8. Understanding the deployment workflow

There are three independent components at work here together:

  • LabAgent: automates the deployment and configuration process.
  • DB Agent: provides the natural-language database interface.
  • Databricks: provides application hosting, data access, SQL compute and AI model serving.

LabAgent runs from the local development environment, while DB Agent is deployed and executed in the Databricks cloud workspace. This approach removes the need for manual configuration while also providing a reusable deployment workflow.

9. Conclusion

This exercise demonstrates how LabAgent can be used to automate the deployment of an AI-powered database application on Databricks.

Through this walkthrough, I explored the local development setup, Databricks CLI authentication, deployment pack configuration, database integration and the application's deployment lifecycle.

The key takeaway is how LabAgent abstracts multiple cloud configuration and provisioning operations into a single repeatable workflow, simplifying the deployment of hands-on AI and data engineering environments.

References

DatabricksLabAgentDB AgentText-to-SQL