Skip to content

Commit af26df0

Browse files
committed
Merge branch 'master' of https://github.com/MicrosoftDocs/azure-docs-pr into groups-update
2 parents 2545b15 + 8ae7087 commit af26df0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+944
-731
lines changed

articles/app-service/webjobs-sdk-get-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ Input bindings simplify code that reads data. For this example, the queue messag
653653
}
654654
```
655655

656-
In this code, `queueTrigger` is a [binding expression](../azure-functions/functions-triggers-bindings.md#binding-expressions-and-patterns), which means it resolves to a different value at runtime. At runtime, it has the contents of the queue message.
656+
In this code, `queueTrigger` is a [binding expression](../azure-functions/functions-bindings-expressions-patterns.md), which means it resolves to a different value at runtime. At runtime, it has the contents of the queue message.
657657

658658
1. Add a `using`:
659659

articles/app-service/webjobs-sdk-how-to.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ static void Main(string[] args)
209209

210210
Input bindings provide a declarative way to make data from Azure or third-party services available to your code. Output bindings provide a way to update data. The [Get started article](webjobs-sdk-get-started.md) shows an example of each.
211211

212-
You can use a method return value for an output binding, by applying the attribute to the method return value. See the example in the Azure Functions [Triggers and bindings](../azure-functions/functions-triggers-bindings.md#using-the-function-return-value) article.
212+
You can use a method return value for an output binding, by applying the attribute to the method return value. See the example in the Azure Functions [Triggers and bindings](../azure-functions/functions-bindings-return-value.md) article.
213213

214214
## Binding types
215215

@@ -442,7 +442,7 @@ public static void CreateThumbnail(
442442
}
443443
```
444444

445-
For more information about binding expressions, see [Binding expressions and patterns](../azure-functions/functions-triggers-bindings.md#binding-expressions-and-patterns) in the Azure Functions documentation.
445+
For more information about binding expressions, see [Binding expressions and patterns](../azure-functions/functions-bindings-expressions-patterns.md) in the Azure Functions documentation.
446446

447447
### Custom binding expressions
448448

articles/azure-functions/TOC.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,19 @@
7373
- name: Scale and hosting
7474
href: functions-scale.md
7575
- name: Triggers and bindings
76-
href: functions-triggers-bindings.md
76+
items:
77+
- name: About triggers and bindings
78+
href: functions-triggers-bindings.md
79+
- name: Binding example
80+
href: functions-bindings-example.md
81+
- name: Register binding extensions
82+
href: functions-bindings-register.md
83+
- name: Binding expression patterns
84+
href: functions-bindings-expressions-patterns.md
85+
- name: Use binding return values
86+
href: functions-bindings-return-value.md
87+
- name: Handle binding errors
88+
href: functions-bindings-errors.md
7789
- name: Languages
7890
items:
7991
- name: Supported languages

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1713,7 +1713,7 @@ The following table explains the binding configuration properties that you set i
17131713
|**name** || Name of the binding parameter that represents the document in the function. |
17141714
|**databaseName** |**DatabaseName** |The database containing the document. |
17151715
|**collectionName** |**CollectionName** | The name of the collection that contains the document. |
1716-
|**id** | **Id** | The ID of the document to retrieve. This property supports [binding expressions](functions-triggers-bindings.md#binding-expressions-and-patterns). Don't set both the **id** and **sqlQuery** properties. If you don't set either one, the entire collection is retrieved. |
1716+
|**id** | **Id** | The ID of the document to retrieve. This property supports [binding expressions](./functions-bindings-expressions-patterns.md). Don't set both the **id** and **sqlQuery** properties. If you don't set either one, the entire collection is retrieved. |
17171717
|**sqlQuery** |**SqlQuery** | An Azure Cosmos DB SQL query used for retrieving multiple documents. The property supports runtime bindings, as in this example: `SELECT * FROM c where c.departmentId = {departmentId}`. Don't set both the **id** and **sqlQuery** properties. If you don't set either one, the entire collection is retrieved.|
17181718
|**connectionStringSetting** |**ConnectionStringSetting**|The name of the app setting containing your Azure Cosmos DB connection string. |
17191719
|**partitionKey**|**PartitionKey**|Specifies the partition key value for the lookup. May include binding parameters.|

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ The following table explains the binding configuration properties that you set i
11611161
|**name** || Name of the binding parameter that represents the document in the function. |
11621162
|**databaseName** |**DatabaseName** |The database containing the document. |
11631163
|**collectionName** |**CollectionName** | The name of the collection that contains the document. |
1164-
|**id** | **Id** | The ID of the document to retrieve. This property supports [binding expressions](functions-triggers-bindings.md#binding-expressions-and-patterns). Don't set both the **id** and **sqlQuery** properties. If you don't set either one, the entire collection is retrieved. |
1164+
|**id** | **Id** | The ID of the document to retrieve. This property supports [binding expressions](./functions-bindings-expressions-patterns.md). Don't set both the **id** and **sqlQuery** properties. If you don't set either one, the entire collection is retrieved. |
11651165
|**sqlQuery** |**SqlQuery** | An Azure Cosmos DB SQL query used for retrieving multiple documents. The property supports runtime bindings, as in this example: `SELECT * FROM c where c.departmentId = {departmentId}`. Don't set both the **id** and **sqlQuery** properties. If you don't set either one, the entire collection is retrieved.|
11661166
|**connection** |**ConnectionStringSetting**|The name of the app setting containing your Azure Cosmos DB connection string. |
11671167
|**partitionKey**|**PartitionKey**|Specifies the partition key value for the lookup. May include binding parameters.|
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
title: Handle Azure Functions bindings errors
3+
description: Learn to handle Azure Functions binding errors
4+
services: functions
5+
documentationcenter: na
6+
author: craigshoemaker
7+
manager: jeconnoc
8+
9+
ms.service: azure-functions
10+
ms.devlang: multiple
11+
ms.topic: reference
12+
ms.date: 01/14/2019
13+
ms.author: cshoe
14+
---
15+
16+
# Handle Azure Functions binding errors
17+
18+
[!INCLUDE [bindings errors intro](../../includes/functions-bindings-errors-intro.md)]
19+
20+
For links to all relevant error topics for the various services supported by Functions, see the [Binding error codes](functions-bindings-error-pages.md#binding-error-codes) section of the [Azure Functions error handling](functions-bindings-error-pages.md) overview topic.

articles/azure-functions/functions-bindings-event-hubs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ The following table explains the binding configuration properties that you set i
425425

426426
## Trigger - event metadata
427427

428-
The Event Hubs trigger provides several [metadata properties](functions-triggers-bindings.md#binding-expressions---trigger-metadata). These properties can be used as part of binding expressions in other bindings or as parameters in your code. These are properties of the [EventData](https://docs.microsoft.com/dotnet/api/microsoft.servicebus.messaging.eventdata) class.
428+
The Event Hubs trigger provides several [metadata properties](./functions-bindings-expressions-patterns.md). These properties can be used as part of binding expressions in other bindings or as parameters in your code. These are properties of the [EventData](https://docs.microsoft.com/dotnet/api/microsoft.servicebus.messaging.eventdata) class.
429429

430430
|Property|Type|Description|
431431
|--------|----|-----------|
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
---
2+
title: Azure Functions trigger and binding example
3+
description: Learn to configure Azure Function bindings
4+
services: functions
5+
documentationcenter: na
6+
author: craigshoemaker
7+
manager: jeconnoc
8+
9+
ms.service: azure-functions
10+
ms.devlang: multiple
11+
ms.topic: reference
12+
ms.date: 02/18/2019
13+
ms.author: cshoe
14+
---
15+
16+
# Azure Functions trigger and binding example
17+
18+
This article demonstrates how to configure a [trigger and bindings](./functions-triggers-bindings.md) in an Azure Function.
19+
20+
Suppose you want to write a new row to Azure Table storage whenever a new message appears in Azure Queue storage. This scenario can be implemented using an Azure Queue storage trigger and an Azure Table storage output binding.
21+
22+
Here's a *function.json* file for this scenario.
23+
24+
```json
25+
{
26+
"bindings": [
27+
{
28+
"type": "queueTrigger",
29+
"direction": "in",
30+
"name": "order",
31+
"queueName": "myqueue-items",
32+
"connection": "MY_STORAGE_ACCT_APP_SETTING"
33+
},
34+
{
35+
"type": "table",
36+
"direction": "out",
37+
"name": "$return",
38+
"tableName": "outTable",
39+
"connection": "MY_TABLE_STORAGE_ACCT_APP_SETTING"
40+
}
41+
]
42+
}
43+
```
44+
45+
The first element in the `bindings` array is the Queue storage trigger. The `type` and `direction` properties identify the trigger. The `name` property identifies the function parameter that receives the queue message content. The name of the queue to monitor is in `queueName`, and the connection string is in the app setting identified by `connection`.
46+
47+
The second element in the `bindings` array is the Azure Table Storage output binding. The `type` and `direction` properties identify the binding. The `name` property specifies how the function provides the new table row, in this case by using the function return value. The name of the table is in `tableName`, and the connection string is in the app setting identified by `connection`.
48+
49+
To view and edit the contents of *function.json* in the Azure portal, click the **Advanced editor** option on the **Integrate** tab of your function.
50+
51+
> [!NOTE]
52+
> The value of `connection` is the name of an app setting that contains the connection string, not the connection string itself. Bindings use connection strings stored in app settings to enforce the best practice that *function.json* does not contain service secrets.
53+
54+
## C# script example
55+
56+
Here's C# script code that works with this trigger and binding. Notice that the name of the parameter that provides the queue message content is `order`; this name is required because the `name` property value in *function.json* is `order`
57+
58+
```cs
59+
#r "Newtonsoft.Json"
60+
61+
using Microsoft.Extensions.Logging;
62+
using Newtonsoft.Json.Linq;
63+
64+
// From an incoming queue message that is a JSON object, add fields and write to Table storage
65+
// The method return value creates a new row in Table Storage
66+
public static Person Run(JObject order, ILogger log)
67+
{
68+
return new Person() {
69+
PartitionKey = "Orders",
70+
RowKey = Guid.NewGuid().ToString(),
71+
Name = order["Name"].ToString(),
72+
MobileNumber = order["MobileNumber"].ToString() };
73+
}
74+
75+
public class Person
76+
{
77+
public string PartitionKey { get; set; }
78+
public string RowKey { get; set; }
79+
public string Name { get; set; }
80+
public string MobileNumber { get; set; }
81+
}
82+
```
83+
84+
## JavaScript example
85+
86+
The same *function.json* file can be used with a JavaScript function:
87+
88+
```javascript
89+
// From an incoming queue message that is a JSON object, add fields and write to Table Storage
90+
// The second parameter to context.done is used as the value for the new row
91+
module.exports = function (context, order) {
92+
order.PartitionKey = "Orders";
93+
order.RowKey = generateRandomId();
94+
95+
context.done(null, order);
96+
};
97+
98+
function generateRandomId() {
99+
return Math.random().toString(36).substring(2, 15) +
100+
Math.random().toString(36).substring(2, 15);
101+
}
102+
```
103+
104+
## Class library example
105+
106+
In a class library, the same trigger and binding information — queue and table names, storage accounts, function parameters for input and output — is provided by attributes instead of a function.json file. Here's an example:
107+
108+
```csharp
109+
public static class QueueTriggerTableOutput
110+
{
111+
[FunctionName("QueueTriggerTableOutput")]
112+
[return: Table("outTable", Connection = "MY_TABLE_STORAGE_ACCT_APP_SETTING")]
113+
public static Person Run(
114+
[QueueTrigger("myqueue-items", Connection = "MY_STORAGE_ACCT_APP_SETTING")]JObject order,
115+
ILogger log)
116+
{
117+
return new Person() {
118+
PartitionKey = "Orders",
119+
RowKey = Guid.NewGuid().ToString(),
120+
Name = order["Name"].ToString(),
121+
MobileNumber = order["MobileNumber"].ToString() };
122+
}
123+
}
124+
125+
public class Person
126+
{
127+
public string PartitionKey { get; set; }
128+
public string RowKey { get; set; }
129+
public string Name { get; set; }
130+
public string MobileNumber { get; set; }
131+
}
132+
```
133+
134+
You now have a working function that is triggered by Azure Table storage which outputs data to a queue.
135+
136+
## Next steps
137+
138+
> [!div class="nextstepaction"]
139+
> [Azure Functions binding expression patterns](./functions-bindings-expressions-patterns.md)

0 commit comments

Comments
 (0)