Stored procedures

Azure Cosmos DB allows for creating stored procedures that can be executed individually and can hold extra logic, which you do not want to share.

If you go to your collection in Data Explorer, you will see the New Stored Procedure tab and the ability to create one:

Stored procedures are written in JavaScript—this allows you to easily access the document's schema (as they are all JSON). What is more, they are registered per collection. Here you can find an example of the easiest stored procedure:

function sample(prefix) {    var context = getContext();    var response = context.getResponse();    response.setBody("Hello, World");}

Get Hands-On Azure for Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.