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
To return [multiple output bindings](./dotnet-isolated-process-guide.md#multiple-output-bindings) in our samples, we'll create a custom return type:
47
+
To return [multiple output bindings](./dotnet-isolated-process-guide.md#multiple-output-bindings) in our samples, we create a custom return type:
48
48
49
49
```cs
50
50
publicstaticclassOutputType
@@ -59,7 +59,7 @@ public static class OutputType
59
59
60
60
### HTTP trigger, write one record
61
61
62
-
The following example shows a [C# function](functions-dotnet-class-library.md) that adds a record to a database, using data provided in an HTTP POST request as a JSON body. The return object is the `OutputType` class we created to handle both an HTTP response and the SQL output binding.
62
+
The following example shows a [C# function](functions-dotnet-class-library.md) that adds a record to a database, using data provided in an HTTP POST request as a JSON body. The return object is the `OutputType` class we created to handle both an HTTP response and the SQL output binding.
63
63
64
64
```cs
65
65
usingSystem;
@@ -133,7 +133,7 @@ CREATE TABLE dbo.RequestLog (
133
133
)
134
134
```
135
135
136
-
To use an additional output binding, we add a class for `RequestLog` and modify our `OutputType` class:
136
+
To use an extra output binding, we add a class for `RequestLog` and modify our `OutputType` class:
The following example shows a SQL output binding in a Java function that adds a record to a table, using data provided in an HTTP POST request as a JSON body. The function takes an additional dependency on the [com.google.code.gson](https://github.com/google/gson) library to parse the JSON body.
381
+
The following example shows a SQL output binding in a Java function that adds a record to a table, using data provided in an HTTP POST request as a JSON body. The function takes another dependency on the [com.google.code.gson](https://github.com/google/gson) library to parse the JSON body.
382
382
383
383
```xml
384
384
<dependency>
@@ -423,7 +423,7 @@ public class PostToDo {
423
423
<aid="http-trigger-write-to-two-tables-java"></a>
424
424
### HTTP trigger, write to two tables
425
425
426
-
The following example shows a SQL output binding in a JavaS function that adds records to a database in two different tables (`dbo.ToDo` and `dbo.RequestLog`), using data provided in an HTTP POST request as a JSON body and multiple output bindings. The function takes an additional dependency on the [com.google.code.gson](https://github.com/google/gson) library to parse the JSON body.
426
+
The following example shows a SQL output binding in a JavaS function that adds records to a database in two different tables (`dbo.ToDo` and `dbo.RequestLog`), using data provided in an HTTP POST request as a JSON body and multiple output bindings. The function takes another dependency on the [com.google.code.gson](https://github.com/google/gson) library to parse the JSON body.
427
427
428
428
```xml
429
429
<dependency>
@@ -868,7 +868,6 @@ The following is sample python code for the function_app.py file:
868
868
import json
869
869
import logging
870
870
import azure.functions as func
871
-
from azure.functions.decorators.core import DataType
872
871
873
872
app = func.FunctionApp()
874
873
@@ -1099,7 +1098,7 @@ The [C# library](functions-dotnet-class-library.md) uses the [SqlAttribute](http
1099
1098
| Attribute property |Description|
1100
1099
|---------|---------|
1101
1100
|**CommandText**| Required. The name of the table being written to by the binding. |
1102
-
|**ConnectionStringSetting**| Required. The name of an app setting that contains the connection string for the database to which data is being written. This isn't the actual connection string and must instead resolve to an environment variable. |
1101
+
|**ConnectionStringSetting**| Required. The name of an app setting that contains the connection string for the database to which data is being written. This value isn't the actual connection string and must instead resolve to an environment variable. |
1103
1102
1104
1103
1105
1104
::: zone-end
@@ -1111,8 +1110,8 @@ In the [Java functions runtime library](/java/api/overview/azure/functions/runti
1111
1110
1112
1111
| Element |Description|
1113
1112
|---------|---------|
1114
-
|**commandText**| Required. The name of the table being written to by the binding. |
1115
-
|**connectionStringSetting**| Required. The name of an app setting that contains the connection string for the database to which data is being written. This isn't the actual connection string and must instead resolve to an environment variable.|
1113
+
|**commandText**| Required. The name of the table being written to by the binding. |
1114
+
|**connectionStringSetting**| Required. The name of an app setting that contains the connection string for the database to which data is being written. This value isn't the actual connection string and must instead resolve to an environment variable.|
1116
1115
|**name**| Required. The unique name of the function binding. |
1117
1116
1118
1117
::: zone-end
@@ -1127,7 +1126,7 @@ The following table explains the properties that you can set on the `options` ob
1127
1126
| Property | Description |
1128
1127
|---------|----------------------|
1129
1128
|**commandText**| Required. The name of the table being written to by the binding. |
1130
-
|**connectionStringSetting**| Required. The name of an app setting that contains the connection string for the database to which data is being written. This isn't the actual connection string and must instead resolve to an environment variable. Optional keywords in the connection string value are [available to refine SQL bindings connectivity](./functions-bindings-azure-sql.md#sql-connection-string). |
1129
+
|**connectionStringSetting**| Required. The name of an app setting that contains the connection string for the database to which data is being written. This value isn't the actual connection string and must instead resolve to an environment variable. Optional keywords in the connection string value are [available to refine SQL bindings connectivity](./functions-bindings-azure-sql.md#sql-connection-string). |
1131
1130
1132
1131
# [Model v3](#tab/nodejs-v3)
1133
1132
@@ -1139,7 +1138,7 @@ The following table explains the binding configuration properties that you set i
1139
1138
|**direction**| Required. Must be set to `out`. |
1140
1139
|**name**| Required. The name of the variable that represents the entity in function code. |
1141
1140
|**commandText**| Required. The name of the table being written to by the binding. |
1142
-
|**connectionStringSetting**| Required. The name of an app setting that contains the connection string for the database to which data is being written. This isn't the actual connection string and must instead resolve to an environment variable. Optional keywords in the connection string value are [available to refine SQL bindings connectivity](./functions-bindings-azure-sql.md#sql-connection-string). |
1141
+
|**connectionStringSetting**| Required. The name of an app setting that contains the connection string for the database to which data is being written. This value isn't the actual connection string and must instead resolve to an environment variable. Optional keywords in the connection string value are [available to refine SQL bindings connectivity](./functions-bindings-azure-sql.md#sql-connection-string). |
1143
1142
1144
1143
---
1145
1144
@@ -1155,7 +1154,7 @@ The following table explains the binding configuration properties that you set i
1155
1154
|**direction**| Required. Must be set to `out`. |
1156
1155
|**name**| Required. The name of the variable that represents the entity in function code. |
1157
1156
|**commandText**| Required. The name of the table being written to by the binding. |
1158
-
|**connectionStringSetting**| Required. The name of an app setting that contains the connection string for the database to which data is being written. This isn't the actual connection string and must instead resolve to an environment variable. Optional keywords in the connection string value are [available to refine SQL bindings connectivity](./functions-bindings-azure-sql.md#sql-connection-string). |
1157
+
|**connectionStringSetting**| Required. The name of an app setting that contains the connection string for the database to which data is being written. This value isn't the actual connection string and must instead resolve to an environment variable. Optional keywords in the connection string value are [available to refine SQL bindings connectivity](./functions-bindings-azure-sql.md#sql-connection-string). |
1159
1158
1160
1159
::: zone-end
1161
1160
@@ -1169,7 +1168,7 @@ The `CommandText` property is the name of the table where the data is to be stor
1169
1168
1170
1169
The output bindings use the T-SQL [MERGE](/sql/t-sql/statements/merge-transact-sql) statement which requires [SELECT](/sql/t-sql/statements/merge-transact-sql#permissions) permissions on the target database.
1171
1170
1172
-
If an exception occurs when a SQL output binding is executed then the function code stop executing. This may result in an error code being returned, such as an HTTP trigger returning a 500 error code. If the `IAsyncCollector` is used in a .NET function then the function code can handle exceptions throw by the call to `FlushAsync()`.
1171
+
If an exception occurs when a SQL output binding is executed, then the function code stops executing. This behavior may result in an error code being returned, such as an HTTP trigger returning a 500 error code. If the `IAsyncCollector` is used in a .NET function, then the function code can handle exceptions throw by the call to `FlushAsync()`.
Copy file name to clipboardExpand all lines: articles/azure-functions/functions-bindings-cosmosdb-v2-output.md
+10-4Lines changed: 10 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -102,7 +102,7 @@ namespace CosmosDBSamplesV2
102
102
103
103
### Queue trigger, write one doc (v4 extension)
104
104
105
-
Apps using [Azure Cosmos DB extension version 4.x](./functions-bindings-cosmosdb-v2.md?tabs=extensionv4) or higher will have different attribute properties which are shown below. The following example shows a [C# function](functions-dotnet-class-library.md) that adds a document to a database, using data provided in message from Queue storage.
105
+
Apps using [Azure Cosmos DB extension version 4.x](./functions-bindings-cosmosdb-v2.md?tabs=extensionv4) or higher have different attribute properties which are shown below. The following example shows a [C# function](functions-dotnet-class-library.md) that adds a document to a database, using data provided in message from Queue storage.
106
106
107
107
```cs
108
108
usingMicrosoft.Azure.WebJobs;
@@ -206,7 +206,7 @@ public String cosmosDbQueryById(
206
206
207
207
#### HTTP trigger, save one document to database via return value
208
208
209
-
The following example shows a Java function whose signature is annotated with `@CosmosDBOutput` and has return value of type `String`. The JSON document returned by the function will be automatically written to the corresponding Azure Cosmos DB collection.
209
+
The following example shows a Java function whose signature is annotated with `@CosmosDBOutput` and has return value of type `String`. The JSON document returned by the function is automatically written to the corresponding Azure Cosmos DB collection.
210
210
211
211
```java
212
212
@FunctionName("WriteOneDoc")
@@ -338,7 +338,7 @@ The following example shows a Java function that writes multiple documents to Az
338
338
}
339
339
```
340
340
341
-
In the [Java functions runtime library](/java/api/overview/azure/functions/runtime), use the `@CosmosDBOutput` annotation on parameters that will be written to Azure Cosmos DB. The annotation parameter type should be `OutputBinding<T>`, where `T` is either a native Java type or a POJO.
341
+
In the [Java functions runtime library](/java/api/overview/azure/functions/runtime), use the `@CosmosDBOutput` annotation on parameters that is written to Azure Cosmos DB. The annotation parameter type should be `OutputBinding<T>`, where `T` is either a native Java type or a POJO.
342
342
343
343
::: zone-end
344
344
::: zone pivot="programming-language-typescript"
@@ -467,7 +467,7 @@ Here's the JavaScript code:
467
467
};
468
468
```
469
469
470
-
For bulk insert form the objects first and then run the stringify function. Here's the JavaScript code:
470
+
For bulk insert form the objects first and then, run the stringify function. Here's the JavaScript code:
471
471
472
472
```javascript
473
473
module.exports=asyncfunction (context) {
@@ -705,6 +705,12 @@ By default, when you write to the output parameter in your function, a document
705
705
> [!NOTE]
706
706
> When you specify the ID of an existing document, it gets overwritten by the new output document.
707
707
708
+
::: zone pivot="programming-language-python"
709
+
710
+
The output function parameter must be defined as `func.Out[func.Document]`. Refer to the [output example](#example) for details.
711
+
712
+
::: zone-end
713
+
708
714
::: zone pivot="programming-language-csharp"
709
715
710
716
The parameter type supported by the Cosmos DB output binding depends on the Functions runtime version, the extension package version, and the C# modality used.
Copy file name to clipboardExpand all lines: articles/azure-functions/functions-bindings-event-grid-output.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -693,6 +693,9 @@ There are two options for outputting an Event Grid message from a function:
693
693
-**Return value**: Set the `name` property in *function.json* to `$return`. With this configuration, the function's return value is persisted as an Event Grid message.
694
694
-**Imperative**: Pass a value to the [set](/python/api/azure-functions/azure.functions.out#set-val--t-----none) method of the parameter declared as an [Out](/python/api/azure-functions/azure.functions.out) type. The value passed to `set` is persisted as an Event Grid message.
695
695
696
+
697
+
The output function parameter must be defined as `func.Out[str]`, `func.Out[bytes]`, `func.Out[func.EventGridOutputEvent]`, or `func.Out[List[func.EventGridOutputEvent]]`. Refer to the [output example](#example) for details.
Copy file name to clipboardExpand all lines: articles/azure-functions/functions-bindings-event-hubs-output.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -458,6 +458,8 @@ There are two options for outputting an Event Hubs message from a function:
458
458
459
459
-**Imperative**: Pass a value to the [set](/python/api/azure-functions/azure.functions.out#set-val--t-----none) method of the parameter declared as an [Out](/python/api/azure-functions/azure.functions.out) type. The value passed to `set` is persisted as an Event Hubs message.
460
460
461
+
The output function parameter must be defined as `func.Out[func.EventHubEvent]` or `func.Out[List[func.EventHubEvent]]`. Refer to the [output example](#example) for details.
The following example demonstrates how to write out to a Service Bus queue in Python. The example depends on whether you use the [v1 or v2 Python programming model](functions-reference-python.md).
272
+
The following example demonstrates how to write out to a Service Bus topics and Service Bus queues in Python. The example depends on whether you use the [v1 or v2 Python programming model](functions-reference-python.md).
273
273
274
274
# [v2](#tab/python-v2)
275
+
This example shows how to write out to a Service Bus topic.
A Service Bus binding definition is defined in *function.json* where *type* is set to `serviceBus`.
310
+
# [v1](#tab/python-v1)
311
+
A Service Bus binding definition is defined in *function.json* where *type* is set to `serviceBus`. This example shows how to write out to a Service Bus topic.
295
312
296
313
```json
297
314
{
@@ -317,7 +334,7 @@ A Service Bus binding definition is defined in *function.json* where *type* is s
317
334
"direction": "out",
318
335
"connection": "AzureServiceBusConnectionString",
319
336
"name": "msg",
320
-
"queueName": "outqueue"
337
+
"topicName": "outTopic"
321
338
}
322
339
]
323
340
}
@@ -328,6 +345,47 @@ In *_\_init_\_.py*, you can write out a message to the queue by passing a value
328
345
```python
329
346
import azure.functions as func
330
347
348
+
defmain(req: azf.HttpRequest, msg: azf.Out[str]):
349
+
msg.set(req.get_body().decode('utf-8'))
350
+
351
+
return'OK'
352
+
```
353
+
354
+
This example shows how to write out to a Service Bus queue.
@@ -564,8 +622,9 @@ Access the output message by using `context.bindings.<name>` where `<name>` is t
564
622
::: zone pivot="programming-language-powershell"
565
623
Output to the Service Bus is available via the `Push-OutputBinding` cmdlet where you pass arguments that match the name designated by binding's name parameter in the *function.json* file.
566
624
::: zone-end
567
-
::: zone pivot="programming-language-python"
568
-
Use the [Azure Service Bus SDK](../service-bus-messaging/index.yml) rather than the built-in output binding.
625
+
::: zone pivot="programming-language-python"
626
+
The output function parameter must be defined as `func.Out[str]` or `func.Out[bytes]`. Refer to the [output example](#example) for details.
627
+
Alternatively, you can use the [Azure Service Bus SDK](../service-bus-messaging/index.yml) rather than the built-in output binding.
569
628
::: zone-end
570
629
For a complete example, see [the examples section](#example).
0 commit comments