Skip to content

This sample shows you how to use the Node.js SDK to interact with Microsoft Azure Cosmos DB.

License

Notifications You must be signed in to change notification settings

Azure-Samples/azure-cosmos-db-sql-api-nodejs-getting-started

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

page_type languages products description urlFragment
sample
javascript
azure
Azure Cosmos DB is a globally distributed multi-model database.
azure-cosmos-db-sql-api-nodejs-getting-started

Developing a Node.js app using the Azure Cosmos DB SQL API

Azure Cosmos DB is a globally distributed multi-model database. One of the supported APIs is the SQL API, which provides a JSON document model with SQL querying and JavaScript procedural logic. This sample shows you how to use Azure Cosmos DB with the SQL API to store and access data from a Node.js application.

Running this sample

This sample is designed to be run as part of the article, "Quickstart: use Node.js to query an Azure Cosmos DB SQL API Database".

  • Before you can run this sample, you must have the following perquisites: _ An active Azure Cosmos DB account - If you don't have an account, refer to the Create an Azure Cosmos DB account article. _ Node.js version v0.10.29 or higher. * Git.
  1. Clone this repository using git clone git@github.com:Azure-Samples/azure-cosmos-db-sql-api-nodejs-getting-started.git cosmosdb

  2. Change directories to the repo using cd cosmosdb

  3. Next, substitute the endpoint and authorization key in app.js with your Azure Cosmos DB account's values.

    const endpoint = "<Your Azure Cosmos account URI>";
    const key = "<Your Azure Cosmos account key>";
    
  4. Run npm install in a terminal to install required npm modules

  5. Run node app.js in a terminal to start your start your node application.

About the code

The code included in this sample is intended to get you quickly started with a Node.js console application that connects to Azure Cosmos DB with the SQL API.

More information