Azure Cosmos DB is a globally distributed multi-model database. One of the supported APIs is the Cassandra API. This is a quick start sample for creation of keyspace, table, insert and querying data in Cassandra API using the gocql driver.
- An Azure account with an active subscription. Create one for free.
- An active Azure Cassandra API account - If you don't have an account, refer to the Create a Cassandra API account article.
- Go installed on your computer, and a working knowledge of Go.
- Git.
Clone the application
git clone https://github.com/Azure-Samples/azure-cosmos-db-cassandra-golang-getting-started
To configure the application, open uprofile.go
and fill in ACCOUNTNAME
, PASSWORD
and CONTACTPOINT
with corresponding values from Azure portal, within your Azure Cosmos DB Cassandra API account.
func main() {
var ACCOUNTNAME = ""
var PASSWORD = ""
var CONTACTPOINT = ""
- Download the Baltimore CyberTrust Root certificate locally from https://cacert.omniroot.com/bc2025.crt.
If you are using a Windows machine, ensure that you have followed the process for properly converting a .crt file into the Microsoft .cer format below. Double-click on the .crt file to open it into the certificate display.
Click
Copy to File
.Press Next on the Certificate Wizard. Select Base-64 encoded X.509 (.CER), then Next.
Select Browse (to locate a destination) and type in a filename. Select Next then Finished.
You should now have a properly formatted .cer file.
-
Change the
<path/to/cert.cer>
inuprofile.go
to point to your new certificate. -
Save
uprofile.go
.
Open up a command window, navigate to where you cloned the application and build it (using go build
). This should create a cassandra.exe file in the same directory.
Run the sample from the same directory by typing uprofile
and hitting return. You should see the following output: