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
@@ -121,26 +121,26 @@ Before you can create an Azure function starting from inside your logic app by u
121
121
122
122
1. In the **Function name** box, provide a name for your function.
123
123
124
-
1. In the **Code** box, add your code to the function template, including the response and payload that you want returned to your logic app after your function finishes running.
124
+
1. In the **Code** box, add your code to the function template, including the response and payload that you want returned to your logic app after your function finishes running. When you're done, select **Create**.
125
125
126
-

126
+
For example:
127
127
128
-
In the template's code, the *`context` object* refers to the message that your logic app sends through the **Request Body** field in a later step. To access the `context` object's properties from inside your function, use this syntax:
128
+

129
129
130
-
`context.body.<property-name>`
130
+
In the template's code, the *`context` object* refers to the message that your logic app sends through the **Request Body** field in a later step. To access the `context` object's properties from inside your function, use this syntax:
131
131
132
-
For example, to reference the `content`property inside the `context` object, use this syntax:
132
+
`context.body.<property-name>`
133
133
134
-
`context.body.content`
134
+
For example, to reference the `content` property inside the `context` object, use this syntax:
135
135
136
-
The template code also includes an `input` variable, which stores the value from the `data` parameter so your function can perform operations on that value. Inside JavaScript functions, the `data` variable is also a shortcut for `context.body`.
136
+
`context.body.content`
137
137
138
-
> [!NOTE]
139
-
> The `body` property here applies to the `context` object and
140
-
> isn't the same as the **Body** token from an action's output,
141
-
> which you might also pass to your function.
138
+
The template code also includes an `input` variable, which stores the value from the `data` parameter so your function can perform operations on that value. Inside JavaScript functions, the `data` variable is also a shortcut for `context.body`.
142
139
143
-
1. When you're done, select **Create**.
140
+
> [!NOTE]
141
+
> The `body` property here applies to the `context` object and
142
+
> isn't the same as the **Body** token from an action's output,
143
+
> which you might also pass to your function.
144
144
145
145
1. In the **Request Body** box, provide your function's input, which must be formatted as a JavaScript Object Notation (JSON) object.
146
146
@@ -164,7 +164,7 @@ To call existing Azure functions from your logic apps, you can add Azure functio
164
164
165
165
1. Under the step where you want to add the function, select **New step**.
166
166
167
-
1. Under **Choose an action**, in the search box, enter "azure functions" as your filter. From the actions list, select this action: **Choose an Azure function**
167
+
1. Under **Choose an action**, in the search box, enter "azure functions" as your filter. From the actions list, select the **Choose an Azure function** action.
Copy file name to clipboardExpand all lines: articles/logic-apps/logic-apps-scenario-function-sb-trigger.md
+23-16Lines changed: 23 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ author: ecfan
8
8
ms.author: estfan
9
9
ms.reviewer: jehollan, klam, LADocs
10
10
ms.topic: article
11
-
ms.date: 06/04/2019
11
+
ms.date: 11/08/2019
12
12
---
13
13
14
14
# Call or trigger logic apps by using Azure Functions and Azure Service Bus
@@ -27,13 +27,13 @@ You can use [Azure Functions](../azure-functions/functions-overview.md) to trigg
27
27
28
28
## Create logic app
29
29
30
-
For this scenario, you have a function running each logic app that you want to trigger. First, create a logic app that starts with an HTTP request trigger. The function calls that endpoint whenever a queue message is received.
30
+
For this scenario, you have a function running each logic app that you want to trigger. First, create a logic app that starts with an HTTP request trigger. The function calls that endpoint whenever a queue message is received.
31
31
32
32
1. Sign in to the [Azure portal](https://portal.azure.com), and create blank logic app.
33
33
34
34
If you're new to logic apps, review [Quickstart: Create your first logic app](../logic-apps/quickstart-create-first-logic-app-workflow.md).
35
35
36
-
1. In the search box, enter "http request". From the triggers list, select this trigger: **When a HTTP request is received**
36
+
1. In the search box, enter `http request`. From the triggers list, select the **When a HTTP request is received** trigger.
@@ -97,9 +97,9 @@ Next, create the function that acts as the trigger and listens to the queue.
97
97
98
98
1. In the Azure portal, open and expand your function app, if not already open.
99
99
100
-
1. Under your function app name, expand **Functions**. On the **Functions** pane, choose**New function**.
100
+
1. Under your function app name, expand **Functions**. On the **Functions** pane, select**New function**.
101
101
102
-

102
+

103
103
104
104
1. Select this template based on whether you created a new function app where you selected .NET as the runtime stack, or you're using an existing function app.
105
105
@@ -111,27 +111,34 @@ Next, create the function that acts as the trigger and listens to the queue.
111
111
112
112

113
113
114
-
1. On the **Azure Service Bus Queue trigger** pane, provide a name for your trigger, and set up the **Service Bus connection** for the queue, which uses the Azure Service Bus SDK `OnMessageReceive()` listener, and choose**Create**.
114
+
1. On the **Azure Service Bus Queue trigger** pane, provide a name for your trigger, and set up the **Service Bus connection** for the queue, which uses the Azure Service Bus SDK `OnMessageReceive()` listener, and select**Create**.
115
115
116
-
1. Write a basic function to call the previously created logic app endpoint by using the queue message as a trigger. This example uses the `application/json` message content type, but you can change this type as necessary. If possible, reuse the instance of HTTP clients. For more information, see [Manage connections in Azure Functions](../azure-functions/manage-connections.md).
116
+
1. Write a basic function to call the previously created logic app endpoint by using the queue message as a trigger. Before you write your function, review these considerations:
117
+
118
+
* This example uses the `application/json` message content type, but you can change this type as necessary.
119
+
120
+
* Due to possible concurrently running functions, high volumes, or heavy loads, avoid instantiating the [HTTPClient class](https://docs.microsoft.com/dotnet/api/system.net.http.httpclient) with the `using` statement and directly creating HTTPClient instances per request. For more information, see [Use HttpClientFactory to implement resilient HTTP requests](https://docs.microsoft.com/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests#issues-with-the-original-httpclient-class-available-in-net-core).
121
+
122
+
* If possible, reuse the instance of HTTP clients. For more information, see [Manage connections in Azure Functions](../azure-functions/manage-connections.md).
123
+
124
+
This example uses the [`Task.Run` method](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task.run) in [asynchronous](https://docs.microsoft.com/dotnet/csharp/language-reference/keywords/async) mode. For more information, see [Asynchronous programming with async and await](https://docs.microsoft.com/dotnet/csharp/programming-guide/concepts/async/).
117
125
118
126
```CSharp
119
127
usingSystem;
120
128
usingSystem.Threading.Tasks;
121
129
usingSystem.Net.Http;
122
130
usingSystem.Text;
123
131
124
-
//Callback URL for previously created Request trigger
132
+
//Can also fetch from App Settings or environment variable
0 commit comments