Skip to content

Commit 256c6da

Browse files
Merge pull request #232321 from mattchenderson/funccosmos
adding sdk types for cosmos
2 parents c3a11f9 + 9e6a34e commit 256c6da

File tree

3 files changed

+106
-3
lines changed

3 files changed

+106
-3
lines changed

articles/azure-functions/dotnet-isolated-process-guide.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,15 @@ The following service-specific bindings are currently included in the preview:
218218

219219
| Service | Trigger | Input binding | Output binding |
220220
|-|-|-|-|
221-
| [Azure Blobs][blob-sdk-types] | Preview support | Preview support | Not yet supported |
221+
| [Azure Blobs][blob-sdk-types] | Preview support | Preview support | Not yet supported<sup>1</sup> |
222+
| [Azure Cosmos DB][cosmos-sdk-types] | SDK types not used<sup>2</sup> | Preview support | Not yet supported<sup>1</sup> |
222223

223224
[blob-sdk-types]: ./functions-bindings-storage-blob.md?tabs=isolated-process%2Cextensionv5&pivots=programming-language-csharp#binding-types
225+
[cosmos-sdk-types]: ./functions-bindings-cosmosdb-v2.md?tabs=isolated-process%2Cextensionv4&pivots=programming-language-csharp#binding-types
226+
227+
<sup>1</sup> Support for SDK type bindings does not presently extend to output bindings.
228+
229+
<sup>2</sup> The Cosmos DB trigger uses the [Azure Cosmos DB change feed](../cosmos-db/change-feed.md) and exposes change feed items as JSON-serializable types. The absence of SDK types is by-design for this scenario.
224230

225231
The [SDK type binding samples](https://github.com/Azure/azure-functions-dotnet-worker/tree/main/samples/WorkerBindingSamples) show examples of working with the various supported types.
226232

articles/azure-functions/functions-bindings-cosmosdb-v2-input.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,7 +1861,8 @@ See the [Example section](#example) for complete examples.
18611861
## Usage
18621862

18631863
::: zone pivot="programming-language-csharp"
1864-
The parameter type supported by the Event Grid trigger depends on the Functions runtime version, the extension package version, and the C# modality used.
1864+
1865+
The parameter type supported by the Cosmos DB input binding depends on the Functions runtime version, the extension package version, and the C# modality used.
18651866

18661867

18671868
# [Functions 2.x+](#tab/functionsv2/in-process)
@@ -1878,7 +1879,7 @@ The parameter type supported by the Event Grid trigger depends on the Functions
18781879

18791880
# [Extension 4.x+](#tab/extensionv4/isolated-process)
18801881

1881-
Only JSON string inputs are currently supported.
1882+
[!INCLUDE [functions-cosmosdb-usage](../../includes/functions-cosmosdb-usage.md)]
18821883

18831884
# [Functions 2.x+](#tab/functionsv2/csharp-script)
18841885

articles/azure-functions/functions-bindings-cosmosdb-v2.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,102 @@ To learn more, see [Update your extensions].
135135

136136
::: zone-end
137137

138+
::: zone pivot="programming-language-csharp"
139+
140+
## Binding types
141+
142+
The binding types supported for .NET depend on both the extension version and C# execution mode, which can be one of the following:
143+
144+
# [In-process class library](#tab/in-process)
145+
146+
An in-process class library is a compiled C# function runs in the same process as the Functions runtime.
147+
148+
# [Isolated process](#tab/isolated-process)
149+
150+
An isolated worker process class library compiled C# function runs in a process isolated from the runtime.
151+
152+
# [C# script](#tab/csharp-script)
153+
154+
C# script is used primarily when creating C# functions in the Azure portal.
155+
156+
---
157+
158+
Choose a version to see binding type details for the mode and version.
159+
160+
# [Extension 4.x and higher](#tab/extensionv4/in-process)
161+
162+
The Azure Cosmos DB extension supports parameter types according to the table below.
163+
164+
| Binding | Parameter types |
165+
|-|-|-|
166+
| Cosmos DB trigger | JSON serializable types<sup>1</sup><br/>`IEnumerable<T>`<sup>2</sup> |
167+
| Cosmos DB input | JSON serializable types<sup>1</sup><br/>`IEnumerable<T>`<sup>2</sup><br/>[CosmosClient] |
168+
| Cosmos DB output | JSON serializable types<sup>1</sup> |
169+
170+
<sup>1</sup> Documents containing JSON data can be deserialized into known plain-old CLR object (POCO) types.
171+
172+
<sup>2</sup> `IEnumerable<T>` provides a collection of documents. Here, `T` is a JSON serializable type. When specified for a trigger, it allows a single invocation to process a batch of documents. When used for an input binding, this allows multiple documents to be returned by the query.
173+
174+
# [Functions 2.x and higher](#tab/functionsv2/in-process)
175+
176+
Earlier versions of the extension exposed types from the now deprecated [Microsoft.Azure.Documents] namespace. Newer types from [Microsoft.Azure.Cosmos] are exclusive to **extension 4.x and higher**.
177+
178+
# [Extension 4.x and higher](#tab/extensionv4/isolated-process)
179+
180+
The isolated worker process supports parameter types according to the table below. Binding to JSON serializeable types is currently the only option that is generally available. Support for binding to types from [Microsoft.Azure.Cosmos] is in preview.
181+
182+
| Binding | Parameter types | Preview parameter types<sup>1</sup> |
183+
|-|-|-|
184+
| Cosmos DB trigger | JSON serializable types<sup>2</sup><br/>`IEnumerable<T>`<sup>3</sup> | *No preview types* |
185+
| Cosmos DB input | JSON serializable types<sup>2</sup><br/>`IEnumerable<T>`<sup>3</sup> | [CosmosClient]<br/>[Database]<br/>[Container] |
186+
| Cosmos DB output | JSON serializable types<sup>2</sup> | *No preview types*<sup>4</sup> |
187+
188+
<sup>1</sup> Preview types require use of [Microsoft.Azure.Functions.Worker.Extensions.CosmosDB 4.1.0-preview1 or later][sdk-types-extension-version], [Microsoft.Azure.Functions.Worker 1.12.1-preview1 or later][sdk-types-worker-version], and [Microsoft.Azure.Functions.Worker.Sdk 1.9.0-preview1 or later][sdk-types-worker-sdk-version]. When developing on your local machine, you will need [Azure Functions Core Tools version 4.0.5000 or later](./functions-run-local.md). When using a preview type, [binding expressions](./functions-bindings-expressions-patterns.md) that rely on trigger data are not supported.
189+
190+
[sdk-types-extension-version]: https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.CosmosDB/4.1.0-preview1
191+
[sdk-types-worker-version]: https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker/1.12.1-preview1
192+
[sdk-types-worker-sdk-version]: https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Sdk/1.9.0-preview1
193+
194+
<sup>2</sup> Documents containing JSON data can be deserialized into known plain-old CLR object (POCO) types.
195+
196+
<sup>3</sup> `IEnumerable<T>` provides a collection of documents. Here, `T` is a JSON serializable type. When specified for a trigger, it allows a single invocation to process a batch of documents. When used for an input binding, this allows multiple documents to be returned by the query.
197+
198+
<sup>4</sup> Support for SDK type bindings does not presently extend to output bindings.
199+
200+
# [Functions 2.x and higher](#tab/functionsv2/isolated-process)
201+
202+
Earlier versions of extensions in the isolated worker process only support binding to JSON serializable types. Additional options are available to **extension 4.x and higher**.
203+
204+
# [Extension 4.x and higher](#tab/extensionv4/csharp-script)
205+
206+
The Azure Cosmos DB extension supports parameter types according to the table below.
207+
208+
| Binding | Parameter types |
209+
|-|-|-|
210+
| Cosmos DB trigger | JSON serializable types<sup>1</sup><br/>`IEnumerable<T>`<sup>2</sup> |
211+
| Cosmos DB input | JSON serializable types<sup>1</sup><br/>`IEnumerable<T>`<sup>2</sup><br/>[CosmosClient] |
212+
| Cosmos DB output | JSON serializable types<sup>1</sup> |
213+
214+
<sup>1</sup> Documents containing JSON data can be deserialized into known plain-old CLR object (POCO) types.
215+
216+
<sup>2</sup> `IEnumerable<T>` provides a collection of documents. Here, `T` is a JSON serializable type. When specified for a trigger, it allows a single invocation to process a batch of documents. When used for an input binding, this allows multiple documents to be returned by the query.
217+
218+
# [Functions 2.x and higher](#tab/functionsv2/csharp-script)
219+
220+
Earlier versions of the extension exposed types from the now deprecated [Microsoft.Azure.Documents] namespace. Newer types from [Microsoft.Azure.Cosmos] are exclusive to **extension 4.x and higher**.
221+
222+
---
223+
224+
[Microsoft.Azure.Cosmos]: /dotnet/api/microsoft.azure.cosmos
225+
[CosmosClient]: /dotnet/api/microsoft.azure.cosmos.cosmosclient
226+
[Database]: /dotnet/api/microsoft.azure.cosmos.database
227+
[Container]: /dotnet/api/microsoft.azure.cosmos.container
228+
229+
[Microsoft.Azure.Documents]: /dotnet/api/microsoft.azure.documents
230+
[DocumentClient]: /dotnet/api/microsoft.azure.documents.client.documentclient
231+
232+
:::zone-end
233+
138234
## Exceptions and return codes
139235

140236
| Binding | Reference |

0 commit comments

Comments
 (0)