Skip to content

Commit dfddda1

Browse files
authored
Merge pull request #233825 from ealsur/users/ealsur/multiplefunc
Cosmos DB: Updating multiple trigger doc for latest extension
2 parents 1b075fe + 7d1e429 commit dfddda1

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

articles/cosmos-db/nosql/how-to-create-multiple-cosmos-db-triggers.md

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: ealsur
55
ms.service: cosmos-db
66
ms.subservice: nosql
77
ms.topic: how-to
8-
ms.date: 07/17/2019
8+
ms.date: 04/07/2023
99
ms.author: maquaran
1010
ms.devlang: csharp
1111
ms.custom: devx-track-csharp
@@ -37,16 +37,15 @@ The goal of this article is to guide you to accomplish the second option.
3737

3838
## Configuring a shared leases container
3939

40-
To configure the shared leases container, the only extra configuration you need to make on your triggers is to add the `LeaseCollectionPrefix` [attribute](../../azure-functions/functions-bindings-cosmosdb-v2-trigger.md#attributes) if you are using C# or `leaseCollectionPrefix` [attribute](../../azure-functions/functions-bindings-cosmosdb-v2-trigger.md) if you are using JavaScript. The value of the attribute should be a logical descriptor of what that particular trigger.
40+
To configure the shared leases container, the only extra configuration you need to make on your triggers is to add the `LeaseContainerPrefix` [attribute](../../azure-functions/functions-bindings-cosmosdb-v2-trigger.md#attributes) if you are using C# or `leaseContainerPrefix` [attribute](../../azure-functions/functions-bindings-cosmosdb-v2-trigger.md) if you are using JavaScript. The value of the attribute should be a logical descriptor of what that particular trigger.
4141

42-
For example, if you have three Triggers: one that sends emails, one that does an aggregation to create a materialized view, and one that sends the changes to another storage, for later analysis, you could assign the `LeaseCollectionPrefix` of "emails" to the first one, "materialized" to the second one, and "analytics" to the third one.
42+
For example, if you have three Triggers: one that sends emails, one that does an aggregation to create a materialized view, and one that sends the changes to another storage, for later analysis, you could assign the `LeaseContainerPrefix` of "emails" to the first one, "materialized" to the second one, and "analytics" to the third one.
4343

4444
The important part is that all three Triggers **can use the same leases container configuration** (account, database, and container name).
4545

46-
A very simple code samples using the `LeaseCollectionPrefix` attribute in C#, would look like this:
46+
A very simple code samples using the `LeaseContainerPrefix` attribute in C#, would look like this:
4747

4848
```cs
49-
using Microsoft.Azure.Documents;
5049
using Microsoft.Azure.WebJobs;
5150
using Microsoft.Azure.WebJobs.Host;
5251
using System.Collections.Generic;
@@ -55,10 +54,10 @@ using Microsoft.Extensions.Logging;
5554
[FunctionName("SendEmails")]
5655
public static void SendEmails([CosmosDBTrigger(
5756
databaseName: "ToDoItems",
58-
collectionName: "Items",
59-
ConnectionStringSetting = "CosmosDBConnection",
60-
LeaseCollectionName = "leases",
61-
LeaseCollectionPrefix = "emails")]IReadOnlyList<Document> documents,
57+
containerName: "Items",
58+
Connection = "CosmosDBConnection",
59+
LeaseContainerName = "leases",
60+
LeaseContainerPrefix = "emails")]IReadOnlyList<MyItem> items,
6261
ILogger log)
6362
{
6463
...
@@ -67,38 +66,38 @@ public static void SendEmails([CosmosDBTrigger(
6766
[FunctionName("MaterializedViews")]
6867
public static void MaterializedViews([CosmosDBTrigger(
6968
databaseName: "ToDoItems",
70-
collectionName: "Items",
71-
ConnectionStringSetting = "CosmosDBConnection",
72-
LeaseCollectionName = "leases",
73-
LeaseCollectionPrefix = "materialized")]IReadOnlyList<Document> documents,
69+
containerName: "Items",
70+
Connection = "CosmosDBConnection",
71+
LeaseContainerName = "leases",
72+
LeaseContainerPrefix = "materialized")]IReadOnlyList<MyItem> items,
7473
ILogger log)
7574
{
7675
...
7776
}
7877
```
7978

80-
And for JavaScript, you can apply the configuration on the `function.json` file, with the `leaseCollectionPrefix` attribute:
79+
And for JavaScript, you can apply the configuration on the `function.json` file, with the `leaseContainerPrefix` attribute:
8180

8281
```json
8382
{
8483
"type": "cosmosDBTrigger",
8584
"name": "documents",
8685
"direction": "in",
87-
"leaseCollectionName": "leases",
88-
"connectionStringSetting": "CosmosDBConnection",
86+
"leaseContainerName": "leases",
87+
"connection": "CosmosDBConnection",
8988
"databaseName": "ToDoItems",
90-
"collectionName": "Items",
91-
"leaseCollectionPrefix": "emails"
89+
"containerName": "Items",
90+
"leaseContainerPrefix": "emails"
9291
},
9392
{
9493
"type": "cosmosDBTrigger",
9594
"name": "documents",
9695
"direction": "in",
97-
"leaseCollectionName": "leases",
98-
"connectionStringSetting": "CosmosDBConnection",
96+
"leaseContainerName": "leases",
97+
"connection": "CosmosDBConnection",
9998
"databaseName": "ToDoItems",
100-
"collectionName": "Items",
101-
"leaseCollectionPrefix": "materialized"
99+
"containerName": "Items",
100+
"leaseContainerPrefix": "materialized"
102101
}
103102
```
104103

0 commit comments

Comments
 (0)