Skip to content

Commit f5ca4d1

Browse files
Merge pull request #229957 from TimShererWithAquent/us2036619g
Freshness Pass User Story: 2036619 How to register and use stored procedures, triggers, and user-defined functions in Azure Cosmos DB
2 parents ec61223 + 9db5c4e commit f5ca4d1

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

articles/cosmos-db/nosql/how-to-use-stored-procedures-triggers-udfs.md

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22
title: Register and use stored procedures, triggers, and user-defined functions in Azure Cosmos DB SDKs
3-
description: Learn how to register and call stored procedures, triggers, and user-defined functions using the Azure Cosmos DB SDKs
3+
description: Learn how to register and call stored procedures, triggers, and user-defined functions using the Azure Cosmos DB SDKs.
44
author: seesharprun
55
ms.service: cosmos-db
66
ms.subservice: nosql
77
ms.topic: how-to
8-
ms.date: 11/03/2021
8+
ms.date: 03/09/2023
99
ms.author: sidandrews
1010
ms.reviewer: jucocchi
1111
ms.devlang: csharp, java, javascript, python
@@ -15,25 +15,25 @@ ms.custom: devx-track-python, devx-track-js, devx-track-csharp
1515
# How to register and use stored procedures, triggers, and user-defined functions in Azure Cosmos DB
1616
[!INCLUDE[NoSQL](../includes/appliesto-nosql.md)]
1717

18-
The API for NoSQL in Azure Cosmos DB supports registering and invoking stored procedures, triggers, and user-defined functions (UDFs) written in JavaScript. Once you've defined one or more stored procedures, triggers, and user-defined functions, you can load and view them in the [Azure portal](https://portal.azure.com/) by using Data Explorer.
18+
The API for NoSQL in Azure Cosmos DB supports registering and invoking stored procedures, triggers, and user-defined functions (UDFs) written in JavaScript. After you define one or more stored procedures, triggers, or user-defined functions, you can load and view them in the [Azure portal](https://portal.azure.com/) by using Data Explorer.
1919

20-
You can use the API for NoSQL SDK across multiple platforms including [.NET v2 (legacy)](sdk-dotnet-v2.md), [.NET v3](sdk-dotnet-v3.md), [Java](sdk-java-v2.md), [JavaScript](sdk-nodejs.md), or [Python](sdk-python.md) SDKs to perform these tasks. If you haven't worked with one of these SDKs before, see the *"Quickstart"* article for the appropriate SDK:
20+
You can use the API for NoSQL SDK across multiple platforms including [.NET v2 (legacy)](sdk-dotnet-v2.md), [.NET v3](sdk-dotnet-v3.md), [Java](sdk-java-v2.md), [JavaScript](sdk-nodejs.md), or [Python](sdk-python.md) SDKs to do these tasks. If you haven't worked with one of these SDKs before, see the quickstart article for the appropriate SDK:
2121

2222
| SDK | Getting started |
2323
| :--- | :--- |
24-
| .NET v3 | [Quickstart: Build a .NET console app to manage Azure Cosmos DB for NoSQL resources](quickstart-dotnet.md) |
24+
| .NET v3 | [Quickstart: Azure Cosmos DB for NoSQL client library for .NET](quickstart-dotnet.md) |
2525
| Java | [Quickstart: Build a Java app to manage Azure Cosmos DB for NoSQL data](quickstart-java.md)
26-
| JavaScript | [Quickstart: Use Node.js to connect and query data from Azure Cosmos DB for NoSQL account](quickstart-nodejs.md) |
27-
| Python | [Quickstart: Build a Python application using an Azure Cosmos DB for NoSQL account](quickstart-python.md) |
26+
| JavaScript | [Quickstart: Azure Cosmos DB for NoSQL client library for Node.js](quickstart-nodejs.md) |
27+
| Python | [Quickstart: Azure Cosmos DB for NoSQL client library for Python](quickstart-python.md) |
2828

2929
## How to run stored procedures
3030

31-
Stored procedures are written using JavaScript. They can create, update, read, query, and delete items within an Azure Cosmos DB container. For more information on how to write stored procedures in Azure Cosmos DB, see [How to write stored procedures in Azure Cosmos DB](how-to-write-stored-procedures-triggers-udfs.md#stored-procedures) article.
31+
Stored procedures are written using JavaScript. They can create, update, read, query, and delete items within an Azure Cosmos DB container. For more information, see [How to write stored procedures](how-to-write-stored-procedures-triggers-udfs.md#stored-procedures).
3232

33-
The following examples show how to register and call a stored procedure by using the Azure Cosmos DB SDKs. Refer to [Create a Document](how-to-write-stored-procedures-triggers-udfs.md#create-an-item) as the source for this stored procedure is saved as `spCreateToDoItem.js`.
33+
The following examples show how to register and call a stored procedure by using the Azure Cosmos DB SDKs. For the source for this stored procedure, saved as *spCreateToDoItem.js*, see [Create items using stored procedures](how-to-write-stored-procedures-triggers-udfs.md#create-an-item).
3434

3535
> [!NOTE]
36-
> For partitioned containers, when executing a stored procedure, a partition key value must be provided in the request options. Stored procedures are always scoped to a partition key. Items that have a different partition key value will not be visible to the stored procedure. This also applied to triggers as well.
36+
> For partitioned containers, when you run a stored procedure, you must provide a partition key value in the request options. Stored procedures are always scoped to a partition key. Items that have a different partition key value aren't visible to the stored procedure. This principle also applies to triggers.
3737
3838
### [.NET SDK v2](#tab/dotnet-sdk-v2)
3939

@@ -161,7 +161,7 @@ CosmosStoredProcedureResponse response = sproc.execute(
161161

162162
### [JavaScript SDK](#tab/javascript-sdk)
163163

164-
The following example shows how to register a stored procedure by using the JavaScript SDK
164+
The following example shows how to register a stored procedure by using the JavaScript SDK:
165165

166166
```javascript
167167
const container = client.database("myDatabase").container("myContainer");
@@ -234,12 +234,12 @@ result = container.scripts.execute_stored_procedure(sproc=created_sproc,params=[
234234

235235
## How to run pre-triggers
236236

237-
The following examples show how to register and call a pre-trigger by using the Azure Cosmos DB SDKs. Refer to the [Pre-trigger example](how-to-write-stored-procedures-triggers-udfs.md#pre-triggers) as the source for this pre-trigger is saved as `trgPreValidateToDoItemTimestamp.js`.
237+
The following examples show how to register and call a pre-trigger by using the Azure Cosmos DB SDKs. For the source of this pre-trigger example, saved as *trgPreValidateToDoItemTimestamp.js*, see [Pre-triggers](how-to-write-stored-procedures-triggers-udfs.md#pre-triggers).
238238

239-
Pre-triggers are passed in the RequestOptions object, when executing an operation, by specifying `PreTriggerInclude` and then passing the name of the trigger in a List object.
239+
When you run an operation by specifying `PreTriggerInclude` and then passing the name of the trigger in a `List` object, pre-triggers are passed in the `RequestOptions` object.
240240

241241
> [!NOTE]
242-
> Even though the name of the trigger is passed as a List, you can still execute only one trigger per operation.
242+
> Even though the name of the trigger is passed as a `List`, you can still run only one trigger per operation.
243243
244244
### [.NET SDK v2](#tab/dotnet-sdk-v2)
245245

@@ -404,7 +404,7 @@ container.create_item(item, {'pre_trigger_include': 'trgPreValidateToDoItemTimes
404404

405405
## How to run post-triggers
406406

407-
The following examples show how to register a post-trigger by using the Azure Cosmos DB SDKs. Refer to the [Post-trigger example](how-to-write-stored-procedures-triggers-udfs.md#post-triggers) as the source for this post-trigger is saved as `trgPostUpdateMetadata.js`.
407+
The following examples show how to register a post-trigger by using the Azure Cosmos DB SDKs. For the source of this post-trigger example, saved as *trgPostUpdateMetadata.js*, see [Post-triggers](how-to-write-stored-procedures-triggers-udfs.md#post-triggers)
408408

409409
### [.NET SDK v2](#tab/dotnet-sdk-v2)
410410

@@ -565,7 +565,7 @@ container.create_item(item, {'post_trigger_include': 'trgPreValidateToDoItemTime
565565

566566
## How to work with user-defined functions
567567

568-
The following examples show how to register a user-defined function by using the Azure Cosmos DB SDKs. Refer to this [User-defined function example](how-to-write-stored-procedures-triggers-udfs.md#udfs) as the source for this post-trigger is saved as `udfTax.js`.
568+
The following examples show how to register a user-defined function by using the Azure Cosmos DB SDKs. For the source of this user-defined function example, saved as *udfTax.js*, see [How to write user-defined functions](how-to-write-stored-procedures-triggers-udfs.md#udfs).
569569

570570
### [.NET SDK v2](#tab/dotnet-sdk-v2)
571571

@@ -705,7 +705,5 @@ results = list(container.query_items(
705705
706706
Learn more concepts and how-to write or use stored procedures, triggers, and user-defined functions in Azure Cosmos DB:
707707
708-
- [Working with Azure Cosmos DB stored procedures, triggers, and user-defined functions in Azure Cosmos DB](stored-procedures-triggers-udfs.md)
709-
- [Working with JavaScript language integrated query API in Azure Cosmos DB](javascript-query-api.md)
710-
- [How to write stored procedures, triggers, and user-defined functions in Azure Cosmos DB](how-to-write-stored-procedures-triggers-udfs.md)
711-
- [How to write stored procedures and triggers using JavaScript Query API in Azure Cosmos DB](how-to-write-javascript-query-api.md)
708+
- [Stored procedures, triggers, and user-defined functions](stored-procedures-triggers-udfs.md)
709+
- [JavaScript query API in Azure Cosmos DB](javascript-query-api.md)

0 commit comments

Comments
 (0)