Skip to content
JavaScript and Node.js library for Azure Cosmos DB
Branch: master
Clone or download
Latest commit 6fb8416 Mar 15, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode Demo and demo debugging fixes (#230) Jan 29, 2019
samples Demo and demo debugging fixes (#230) Jan 29, 2019
ts-test TS Consumer Smoke Test (#199) Nov 30, 2018
.gitignore dev dependencies update (#258) Mar 12, 2019
.npmignore 2.1.0 Dec 4, 2018
.travis.yml Node.js SDK Release 1.7.0 Apr 26, 2016
LICENSE TypeScript conversion (#3) Jun 4, 2018
PoliCheckExclusions.txt Update Mar 9, 2019
SDK + Samples Workspace.code-workspace
tsconfig.json 2.1.1 (#204) Dec 5, 2018
tslint.json 2.1.1 (#204) Dec 5, 2018
webpack.config.js 2.1.1 (#204) Dec 5, 2018

Microsoft Azure Cosmos JavaScript SDK

This project provides JavaScript & Node.js SDK library for SQL API of Azure Cosmos Database Service. This project also includes samples, tools, and utilities.

latest npm badge Build Status Build Status

// JavaScript
const cosmos = require("@azure/cosmos");
const CosmosClient = cosmos.CosmosClient;

const endpoint = "[hostendpoint]"; // Add your endpoint
const masterKey = "[database account masterkey]"; // Add the masterkey of the endpoint
const client = new CosmosClient({ endpoint, auth: { masterKey } });

const databaseDefinition = { id: "sample database" };
const collectionDefinition = { id: "sample collection" };
const documentDefinition = { id: "hello world doc", content: "Hello World!" };

async function helloCosmos() {
  const { database: db } = await client.databases.create(databaseDefinition);
  console.log("created db");

  const { container } = await db.containers.create(collectionDefinition);
  console.log("created collection");

  const { body } = await container.items.create(documentDefinition);
  console.log("Created item with content: ", body.content);

  await db.delete();
  console.log("Deleted database");

helloCosmos().catch(err => {

Useful links

Need Help?

Tweet us with #CosmosDB and we'll respond on Twitter. Be sure to check out the Microsoft Azure Developer Forums on MSDN or the Developer Forums on Stack Overflow if you have trouble with the provided code.

Contribute Code or Provide Feedback

For our rules and guidelines on contributing, please see [Microsoft's contributor guide].(

For information on how build and test this repo, please see ./

If you encounter any bugs with the library please file an issue in the Issues section of the project.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.