CompanyDecember 14, 2022

Accelerate your Cassandra development and automation with the Astra CLI

Greg Stachnick
Greg StachnickProduct, DataStax
Accelerate your Cassandra development and automation with the Astra CLI

We are pleased to announce the release of the new DataStax Astra Command Line Interface (CLI). For Apache Cassandra developers using DataStax Astra DB, the Astra CLI is a one stop shop for managing your Astra resources through scripts or in your local terminal. It covers a wide variety of capabilities including:

  • Creation and management for Astra DB & Astra Streaming artifacts
  • Querying & data loading
  • Organization and user management
  • Security and token configuration

Astra Command Line Interface (CLI)Figure 1: Astra Command Line Interface (CLI)

Many developers prefer to work from the command line and having to switch contexts to a web UI can break up their development flow. The Astra CLI can run from any terminal or embedded integrated development environment (IDE) console to quickly connect to your Astra account and artifacts. This allows you to easily run simple development tasks like creating or resuming a database, checking the status of a streaming tenant, or running a query. 

For DevOps engineers, the CLI provides the best way to streamline automation scripts which perform typical maintenance tasks or run test scenarios, which can then be incorporated into your CI/CD processes. With just a few commands, you can provision a new Astra database, load data with DSBulk, run tests, validate with queries using CQLSH, manage and configure Astra DB, and tear down the environment. 

For management, configuration and operation of Astra DB, the CLI leverages the functionality provided by Astra DB’s REST-based DevOps API, much in the same way the web-based Astra DB Console does.  

Installation

To get started with the Astra CLI on MAC laptops, run the following Homebrew installation command:

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
brew install datastax/astra-cli/astra-cli
This will install the Astra CLI through the Homebrew package manager. Additional installation options for Linux and Windows can be found <a href="https://awesome-astra.github.io/docs/pages/astra/astra-cli/#installation">here</a>.
Once installed, run the setup utility to authenticate to your Astra account using your application token:
<img src="https://cdn.sanity.io/images/bbnkhnhl/production/fd7d4b8cbe7b289581f94cdaf8720d9cab5f3ece-640x480.png" alt="" width="640" height="480" />
The Astra CLI is self-documented so that you can quickly lookup the commands and their options, either from the embedded help system or by using TAB completion. For example, to get help on database commands, just use:
astra help db
<img src="https://cdn.sanity.io/images/bbnkhnhl/production/fbefc11a1c1780b6ded149e9401bcf79e6b83c83-1018x452.png" />
The CLI will also download, install, and configure additional utilities as needed, such as:
<ul>
<li style="font-weight: 400;" aria-level="1">CQLSH to execute CQL queries</li>
<li style="font-weight: 400;" aria-level="1">DSBulk to load and unload data</li>
<li style="font-weight: 400;" aria-level="1">pulsar-shell to configure Astra Streaming tenants, producers, and consumers</li>
</ul>
Now we are off to the races and ready to work with Astra. 
<h2 id="create-your-first-database-1">Create your first database</h2>
To create a new database simply provide the database and optional keyspace name. 
astra db create demo
<img src="https://cdn.sanity.io/images/bbnkhnhl/production/44c5b77ebbb1a7190d6ff2f5defad4a0896afe87-1226x204.png" />
Once the database is created, you can list your databases using list.
astra db list

Check out the video below to learn about data loading and querying:

Summary

The Astra CLI is a lightweight tool that fits neatly into any developer toolbox. Whether you are writing automated test suites, release management pipelines, or just want to administrate Astra DB and Astra Streaming from the keyboard versus your mouse, the Astra CLI is here to help. 

While we have only scratched the surface, there is so much more that you can do with the CLI including managing multiple organizations, defining users and roles, and automating your Astra Streaming lifecycle. For more information, check out the resources below or try out one of the new Getting Started guides in Astra itself.

This is only the first release, but you can expect more features and functionality for the Astra CLI in the near future. We’ll add support for more package managers which simplify installation like SDKMan and Yum, security configuration for Private Link with AWS and Azure, and configuration options for Change Data Capture (CDC).

Happy scripting!

Resources

Discover more
DataStax Astra DBReleasesApache Cassandra®
Share

One-stop Data API for Production GenAI

Astra DB gives JavaScript developers a complete data API and out-of-the-box integrations that make it easier to build production RAG apps with high relevancy and low latency.