Azure Cosmos DB Node.js examples
The Azure Cosmos DB DocumentDB API or SQL (DocumentDB) API is now known as Azure Cosmos DB SQL API. You don't need to change anything to continue running your apps built with DocumentDB API. The functionality remains the same.
Sample solutions that perform CRUD operations and other common operations on Azure Cosmos DB resources are included in the azure-documentdb-nodejs GitHub repository. This article provides:
- Links to the tasks in each of the Node.js example project files.
- Links to the related API reference content.
If you don't have an Azure subscription, create a free account before you begin.
- You can activate Visual Studio subscriber benefits: Your Visual Studio subscription gives you credits every month that you can use for paid Azure services.
Alternatively, you can Try Azure Cosmos DB for free without an Azure subscription, free of charge and commitments. Or you can use the Azure Cosmos DB Emulator for this tutorial with a URI of https://localhost:8081 and a key of
You also need the Node.js SDK.
Each sample is self-contained, it sets itself up and cleans up after itself. As such, the samples issue multiple calls to DocumentClient.createCollection. Each time this is done your subscription will be billed for 1 hour of usage per the performance tier of the collection being created.
For more information about indexing, see Azure Cosmos DB indexing policies.
Server-side programming examples
|Create a stored procedure||DocumentClient.createStoredProcedure|
|Execute a stored procedure||DocumentClient.executeStoredProcedure|
For more information about server-side programming, see Azure Cosmos DB server-side programming: Stored procedures, database triggers, and UDFs.
|Use a HashPartitionResolver||HashPartitionResolver|
For more information about partitioning data in Azure Cosmos DB, see Partition and scale data in Azure Cosmos DB.