What is your rating of GIT Belgaum
Quick start: Build a Cassandra app with the Node.js SDK and Azure Cosmos DB
- 6 minutes to read
APPLIES TO: Cassandra API
In this quickstart, you'll create an Azure Cosmos DB Cassandra API account and use a GitHub cloned Cassandra-Node.js app to create a Cassandra database and container. Azure Cosmos DB is a multi-model database service that enables you to quickly create and query document, table, key-value, and graph databases using global distribution and scale-out capabilities.
If you don't have an Azure subscription, create a free account before you begin. Alternatively, you can try Azure Cosmos DB without an Azure subscription - free of charge and with no obligation.
You also need:
Create a database account
Before creating a document database, you must create a Cassandra account using Azure Cosmos DB.
Sign in to the Azure portal in a new browser window.
Select in the menu on the left Create resource out.
Select on the side New the options Databases > Azure Cosmos DB out.
Enter on the side Create an Azure Cosmos DB account Enter the settings for the new Azure Cosmos DB account:
attitude value DESCRIPTION Subscription Your subscription Select the Azure subscription that you want to use for this Azure Cosmos DB account. Resource group Create new
Then enter the same name as the account name.
Choose Create new. Then enter a new resource group name for your account. For simplicity, use the same name as the Azure Cosmos account name. Account name Enter a unique name. Enter a unique name that identifies your Azure Cosmos DB account. The account URI is cassandra.cosmos.azure.com and is appended to your unique account name.
The account name can only contain lowercase letters, numbers, and hyphens (-) and must be between 3 and 31 characters long.
API Cassandra The API determines the type of account to be created. Azure Cosmos DB provides five APIs: Core API (SQL) for Document Databases, Gremlin API for Graph Databases, MongoDB API for Document Databases, Azure Tables API, and Cassandra API. You need to create a separate account for each API.
Choose Cassandra because in this quickstart you will create a table that can be used with the Cassandra API.
More information about the Cassandra API
position Select the region that is closest to your users. Select a geographic location to host your Azure Cosmos DB account. Use a location that is closest to your users for quick access to the data. Capacity mode Provisioned throughput or serverless Choose Provisioned Throughput to create an account in Provisioned Throughput mode. Choose Serverless to create an account in Serverless mode.
Choose Rate + create out. You can use the sections network, Fuse, Encryption and Tags skip.
It takes a few minutes to create an account. Wait for the portal to open the page Congratulations! Your Azure Cosmos DB account has been created is shown.
Cloning the sample application
In this step, we clone a Cassandra API app from GitHub, set the connection string, and run the app. You'll find how easy it is to work with data programmatically.
Open a command prompt. Create a new folder called. Then close the command prompt.
Open a Git terminal window, e.g. git bash. Use the command to switch to the new folder to install the sample app.
Run the following command to clone the sample repository. This command makes a copy of the sample app on your computer.
Install the Node.js dependencies with npm.
Check the code
This step is optional. If you want to learn how the code creates the database resources, you can take a look at the following code snippets. The code snippets are all taken from the file in the folder. Otherwise, you can proceed to updating the connection string.
The username and password values were set on the Connection String page of the Azure portal.
is initialized with contactPoint information. The contactPoint is obtained from the Azure portal.
connects to the Azure Cosmos DB Cassandra API.
A new keyspace is created.
A new table is created.
Key-value entities are inserted.
Query to get all key values.
Query to get a key value.
Close the connection.
Update the connection string
Now switch back to the Azure portal to get the connection string information and copy it into the app. Specifying the connection string enables your app to communicate with your hosted database.
In your Azure Cosmos DB account in the Azure portal, select Connection string out.
Use the button on the right side of the screen to copy the top value (the contact point).
Open the file.
On line 9, replace with the contact point value from the portal.
Line 9 should now look something like this:
Copy the username value from the portal and overwrite it in line 2.
Line 2 should now look something like this:
Copy the value for the password from the portal and overwrite it on line 8.
Line 8 should now look something like this:
Replace REGION with the Azure region in which you created this resource.
Save the file.
Run the Node.js app
In the Terminal window, make sure you are in the samples directory that you cloned earlier:
Run your Node application:
Check the results from the command line.
Press CTRL + C to end the program and close the console window.
In the Azure portal, open the Data explorerto query, modify, and use this new data.
Review SLAs in the Azure portal
The Azure portal monitors throughput, storage, availability, latency and consistency of your Cosmos DB account. Azure Cosmos DB Service Level Agreement (SLA) metrics graphs show the SLA versus actual performance. This collection of metrics makes the monitoring of your SLAs transparent.
To review metrics and SLAs:
From the navigation menu of your Cosmos DB account, select the option Metric out.
Select a tab (such as waiting period) and select a time period on the right. Compare lines Indeed and SLA in the diagrams.
Review the metrics on the other tabs.
Cleaning up resources
When you have completed your app and the Azure Cosmos DB account, you can delete the Azure resources that you created so that there are no further charges. To delete the resources:
Search using the Azure portal search bar Resource groupsand select the appropriate option.
From the list, select the resource group that you created for this quickstart.
Select on the side Overview the resource group option Delete resource group out.
In the next window, enter the name of the resource group to be deleted, then select Clear out.
In this quick start guide, you learned how to create an Azure Cosmos DB account with Cassandra API and run a Cassandra-Node.js app that creates a Cassandra database and a Cassandra container. You are now ready to import additional data into your Azure Cosmos DB account.
Is this page helpful?
- Why is the tomato a fruit
- What are some cosmetic uses of petroleum jelly
- What's another word for poop
- What is the weakest branch of international law
- What religions allow people to go
- How native react works on Android
- What are the properties of basic particles
- Does the Samsung Galaxy J5 support wireless charging?
- What is your opinion on Erdogan
- Inhalation of whitener affects sleep
- What is the best HR software
- Is your diet sustainable?
- A schizophrenic sociopath is possible
- How accurate is the rabbit psychopath test
- What makes a good dialogue
- What are the problems with a baby
- Are wolves and dogs the same species?
- How about a hassle-free English method?
- What is observation and inference
- What do people not know in life
- Minecraft is still cool
- Who is the hottest K-Pop artist
- What are the best drama techniques
- Which nation makes the least mistakes?