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.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Azure Cosmos DB input binding for Azure Functions 2.x and higher
@@ -18,6 +18,9 @@ For information on setup and configuration details, see the [overview](./functio
18
18
> When the collection is [partitioned](../cosmos-db/partitioning-overview.md#logical-partitions), lookup operations must also specify the partition key value.
19
19
>
20
20
21
+
::: zone pivot="programming-language-javascript,programming-language-typescript"
The following example shows a [TypeScript function](functions-reference-node.md?tabs=typescript) that reads a single document and updates the document's text value.
The following example shows a [TypeScript function](functions-reference-node.md?tabs=typescript) that retrieves a single document. The function is triggered by an HTTP request that uses a query string to specify the ID and partition key value to look up. That ID and partition key value are used to retrieve a `ToDoItem` document from the specified database and collection.
The following example shows a [TypeScript function](functions-reference-node.md?tabs=typescript) that retrieves a single document. The function is triggered by an HTTP request that uses route data to specify the ID and partition key value to look up. That ID and partition key value are used to retrieve a `ToDoItem` document from the specified database and collection.
### Queue trigger, get multiple docs, using SqlQuery
791
+
792
+
The following example shows a [TypeScript function](functions-reference-node.md?tabs=typescript) that retrieves multiple documents specified by a SQL query, using a queue trigger to customize the query parameters.
793
+
794
+
The queue trigger provides a parameter `departmentId`. A queue message of `{ "departmentId" : "Finance" }` would return all records for the finance department.
TypeScript samples are not documented for model v3.
803
+
804
+
---
805
+
727
806
::: zone-end
728
807
::: zone pivot="programming-language-javascript"
729
808
@@ -738,7 +817,13 @@ This section contains the following examples that read a single document by spec
738
817
739
818
### Queue trigger, look up ID from JSON
740
819
741
-
The following example shows an Azure Cosmos DB input binding in a *function.json* file and a [JavaScript function](functions-reference-node.md) that uses the binding. The function reads a single document and updates the document's text value.
820
+
The following example shows a [JavaScript function](functions-reference-node.md) that reads a single document and updates the document's text value.
The following example shows a [JavaScript function](functions-reference-node.md) that retrieves a single document. The function is triggered by an HTTP request that uses a query string to specify the ID and partition key value to look up. That ID and partition key value are used to retrieve a `ToDoItem` document from the specified database and collection.
The following example shows a [JavaScript function](functions-reference-node.md) that retrieves a single document. The function is triggered by an HTTP request that uses route data to specify the ID and partition key value to look up. That ID and partition key value are used to retrieve a `ToDoItem` document from the specified database and collection.
### Queue trigger, get multiple docs, using SqlQuery
898
1000
899
-
The following example shows an Azure Cosmos DB input binding in a *function.json* file and a [JavaScript function](functions-reference-node.md) that uses the binding. The function retrieves multiple documents specified by a SQL query, using a queue trigger to customize the query parameters.
1001
+
The following example shows a [JavaScript function](functions-reference-node.md) that retrieves multiple documents specified by a SQL query, using a queue trigger to customize the query parameters.
900
1002
901
1003
The queue trigger provides a parameter `departmentId`. A queue message of `{ "departmentId" : "Finance" }` would return all records for the finance department.
::: zone pivot="programming-language-javascript,programming-language-powershell,programming-language-python"
1571
+
::: zone pivot="programming-language-javascript,programming-language-typescript,programming-language-powershell,programming-language-python"
1463
1572
## Configuration
1464
1573
::: zone-end
1465
1574
1466
1575
::: zone pivot="programming-language-python"
1467
1576
_Applies only to the Python v1 programming model._
1468
1577
1469
1578
::: zone-end
1470
-
::: zone pivot="programming-language-javascript,programming-language-powershell,programming-language-python"
1579
+
::: zone pivot="programming-language-javascript,programming-language-typescript"
1580
+
1581
+
# [Model v4](#tab/nodejs-v4)
1582
+
1583
+
The following table explains the properties that you can set on the `options` object passed to the `input.cosmosDB()` method. The `type`, `direction`, and `name` properties don't apply to the v4 model.
1584
+
1585
+
# [Model v3](#tab/nodejs-v3)
1471
1586
1472
1587
The following table explains the binding configuration properties that you set in the *function.json* file, where properties differ by extension version:
1473
1588
1589
+
---
1590
+
1591
+
::: zone-end
1592
+
::: zone pivot="programming-language-powershell,programming-language-python"
1593
+
1594
+
The following table explains the binding configuration properties that you set in the *function.json* file, where properties differ by extension version:
1595
+
1596
+
::: zone-end
1597
+
::: zone pivot="programming-language-javascript,programming-language-typescript,programming-language-powershell,programming-language-python"
@@ -1531,8 +1656,18 @@ See [Binding types](./functions-bindings-cosmosdb-v2.md?tabs=isolated-process%2C
1531
1656
::: zone pivot="programming-language-java"
1532
1657
From the [Java functions runtime library](/java/api/overview/azure/functions/runtime), the [@CosmosDBInput](/java/api/com.microsoft.azure.functions.annotation.cosmosdbinput) annotation exposes Azure Cosmos DB data to the function. This annotation can be used with native Java types, POJOs, or nullable values using `Optional<T>`.
1533
1658
::: zone-end
1534
-
::: zone pivot="programming-language-javascript,programming-language-powershell"
1535
-
Updates are not made automatically upon function exit. Instead, use `context.bindings.<documentName>In` and `context.bindings.<documentName>Out` to make updates. See the [JavaScript example](#example) for more detail.
1659
+
::: zone pivot="programming-language-javascript,programming-language-typescript"
1660
+
1661
+
# [Model v4](#tab/nodejs-v4)
1662
+
1663
+
Access the document by using `context.extraInputs.get()`.
1664
+
1665
+
# [Model v3](#tab/nodejs-v3)
1666
+
1667
+
Access the document by using `context.bindings.<name>` where `<name>` is the value specified in the `name` property of *function.json*.
1668
+
1669
+
---
1670
+
1536
1671
::: zone-end
1537
1672
::: zone pivot="programming-language-powershell"
1538
1673
Updates to documents are not made automatically upon function exit. To update documents in a function use an [output binding](./functions-bindings-cosmosdb-v2-input.md). See the [PowerShell example](#example) for more detail.
0 commit comments