Developing a Node.js app with DocumentDB using Azure Cosmos DB

Andrew Hoh 提供
在 GitHub 上編輯

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

Running this sample

  • Before you can run this sample, you must have the following perquisites:

  • Clone this repository using git clone cosmosdb

  • Change directories to the repo using cd cosmosdb

  • Next, substitute the endpoint and authorization key in config.js with your Cosmos DB account's values.

    config.endpoint = "~your DocumentDB endpoint here~";
    config.authKey = "~your auth key here~";
  • Run npm install in a terminal to install required npm modules

  • 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 DocumentDB API.

More information