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
Copy file name to clipboardExpand all lines: articles/logic-apps/call-azure-functions-from-workflows.md
+39-29Lines changed: 39 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,8 @@ services: logic-apps
5
5
ms.suite: integration
6
6
ms.reviewer: estfan, azla
7
7
ms.topic: how-to
8
-
ms.date: 08/07/2024
8
+
ai.usage: ai-assisted
9
+
ms.date: 10/21/2024
9
10
---
10
11
11
12
# Call Azure Functions from workflows in Azure Logic Apps
@@ -89,9 +90,9 @@ This how-to guide shows how to call an existing Azure function from your Consump
89
90
> The **`body`** property here applies to the **`context`** object and isn't the same as
90
91
> the **Body** token in an action's output, which you might also pass to your function.
91
92
92
-
- Your function can't use custom routes unless you defined an [OpenAPI definition](../azure-functions/functions-openapi-definition.md) ([Swagger file](https://swagger.io/)).
93
+
- Your function can't use custom routes unless you defined an [OpenAPI definition](../azure-functions/functions-openapi-definition.md).
93
94
94
-
When you have an OpenAPI definition for your function, the workflow designer gives you a richer experience when you work with function parameters. Before your workflow can find and access functions that have OpenAPI definitions, [set up your function app by following these steps](#function-swagger).
95
+
When you have an OpenAPI definition for your function, the workflow designer gives you a richer experience when you work with function parameters. Before your workflow can find and access functions that have OpenAPI definitions, [set up your function app by following these steps](#open-ai-definition).
95
96
96
97
- A Consumption or Standard logic app workflow that starts with any trigger.
97
98
@@ -103,11 +104,11 @@ This how-to guide shows how to call an existing Azure function from your Consump
103
104
104
105
## Tips for working with Azure functions
105
106
106
-
<a name="function-swagger"></a>
107
+
<a name="open-ai-definition"></a>
107
108
108
-
### Generate an OpenAPI definition or Swagger file for your function
109
+
### Find functions with OpenAPI definitions
109
110
110
-
For a richer experience when you work with function parameters in the workflow designer, [generate an OpenAPI definition](../azure-functions/functions-openapi-definition.md) or [Swagger file](https://swagger.io/) for your function. To set up your function app so that your workflow can find and use functions that have Swagger descriptions, follow these steps:
111
+
To set up your function app so that your workflow can find and use functions that have OpenAPI definitions, follow these steps:
111
112
112
113
1. In the [Azure portal](https://portal.azure.com), open your function app. Make sure that the function app is actively running.
113
114
@@ -148,6 +149,16 @@ Here's what happens inside this function:
148
149
149
150
After you create your function in Azure, follow the steps to [add an Azure function to your workflow](#add-function-logic-app).
150
151
152
+
### Pass URI parameters to a function
153
+
154
+
If you have to pass a URI parameter to your function, you can use query parameters in the function's endpoint URL, for example:
155
+
156
+
1. In the workflow designer with the function information pane open, open the **Advanced parameters** list, select **Queries**.
157
+
158
+
A row appears where you can enter parameter input as key-value pairs, for example:
159
+
160
+
:::image type="content" source="media/call-azure-functions-from-workflows/queries-parameter.png" alt-text="Screenshot shows function information pane with Queries parameter and example key-value inputs.":::
161
+
151
162
<aname="add-function-logic-app"></a>
152
163
153
164
## Add a function to your workflow (Consumption + Standard workflows)
@@ -160,35 +171,35 @@ To call an Azure function from your workflow, you can add that functions like an
160
171
161
172
1. In the designer, [follow these general steps to add the **Azure Functions** action named **Choose an Azure function**](create-workflow-with-trigger-or-action.md?tabs=consumption#add-action).
162
173
163
-
1. In the **Create Connection** pane, follow these steps:
174
+
1. In the **Add an action** pane, follow these steps:
164
175
165
-
1. Provide a **Connection Name** for the connection to your function app.
176
+
1.From the function apps list, select your function app, select the function, and then select **Add action**, for example:
166
177
167
-
1. From the function apps list, select your function app.
178
+
:::image type="content" source="media/call-azure-functions-from-workflows/select-function-app-function-consumption.png" alt-text="Screenshot shows Consumption workflow with a selected function app and function.":::
168
179
169
-
1. From the functions list, select the function, and then select **Add Action**, for example:
180
+
1.After the function's information box appears, follow these steps:
170
181
171
-
:::image type="content" source="media/call-azure-functions-from-workflows/select-function-app-function-consumption.png" alt-text="Screenshot shows Consumption workflow with a selected function app and function." lightbox="media/call-azure-functions-from-workflows/select-function-app-function-consumption.png":::
182
+
1. For **Request Body**, provide your function's input, which must use the format for a JavaScript Object Notation (JSON) object, for example:
172
183
173
-
1. In the selected function's action box, follow these steps:
184
+
`{"context": <selected-input> }`
174
185
175
-
1. For **Request Body**, provide your function's input, which must be formatted as a JavaScript Object Notation (JSON) object. This input is the *context object* payload or message that your workflow sends to your function.
186
+
This input is the *context object* payload or message that your workflow sends to your function.
176
187
177
188
- To select tokens that represent outputs from previous steps, select inside the **Request Body** box, and then select the option to open the dynamic content list (lightning icon).
178
189
179
190
- To create an expression, select inside the **Request Body** box, and then select option to open the expression editor (formula icon).
180
191
181
192
The following example specifies a JSON object with the **`content`** attribute and a token representing the **From** output from the email trigger as the **Request Body** value:
182
193
183
-
:::image type="content" source="media/call-azure-functions-from-workflows/function-request-body-example-consumption.png" alt-text="Screenshot shows Consumption workflow and a function with a Request Body example for the context object payload." lightbox="media/call-azure-functions-from-workflows/function-request-body-example-consumption.png":::
194
+
:::image type="content" source="media/call-azure-functions-from-workflows/function-request-body-example-consumption.png" alt-text="Screenshot shows Consumption workflow and a function with a Request Body example for the context object payload.":::
184
195
185
196
Here, the context object isn't cast as a string, so the object's content gets added directly to the JSON payload. Here's the complete example:
186
197
187
-
:::image type="content" source="media/call-azure-functions-from-workflows/request-body-example-complete.png" alt-text="Screenshot shows Consumption workflow and a function with a complete Request Body example for the context object payload." lightbox="media/call-azure-functions-from-workflows/request-body-example-complete.png":::
198
+
:::image type="content" source="media/call-azure-functions-from-workflows/request-body-example-complete.png" alt-text="Screenshot shows Consumption workflow and a function with a complete Request Body example for the context object payload.":::
188
199
189
200
If you provide a context object other than a JSON token that passes a string, a JSON object, or a JSON array, you get an error. However, you can cast the context object as a string by enclosing the token in quotation marks (**""**), for example, if you wanted to use the **Received Time** token:
190
201
191
-
:::image type="content" source="media/call-azure-functions-from-workflows/function-request-body-string-cast-example.png" alt-text="Screenshot shows Consumption workflow and a Request Body example that casts context object as a string." lightbox="media/call-azure-functions-from-workflows/function-request-body-string-cast-example.png":::
202
+
:::image type="content" source="media/call-azure-functions-from-workflows/function-request-body-string-cast-example.png" alt-text="Screenshot shows Consumption workflow and a Request Body example that casts context object as a string.":::
192
203
193
204
1. To specify other details such as the method to use, request headers, query parameters, or authentication, open the **Advanced parameters** list, and select the parameters that you want. For authentication, your options differ based on your selected function. For more information, review [Enable authentication for functions](#enable-authentication-functions).
194
205
@@ -202,36 +213,35 @@ To call an Azure function from your workflow, you can add that functions like an
202
213
203
214
1. Provide a **Connection Name** for the connection to your function app.
204
215
205
-
1. From the function apps list, select your function app.
216
+
1. From the function apps list, select your function app, select the function, and then select **Create new**, for example:
206
217
207
-
1. From the functions list, select the function, and then select **Create New**, for example:
218
+
:::image type="content" source="media/call-azure-functions-from-workflows/select-function-app-function-standard.png" alt-text="Screenshot shows Standard workflow designer with selected function app and function.":::
208
219
209
-
:::image type="content" source="media/call-azure-functions-from-workflows/select-function-app-function-standard.png" alt-text="Screenshot shows Standard workflow designer with selected function app and function." lightbox="media/call-azure-functions-from-workflows/select-function-app-function-standard.png":::
220
+
1. After the function's information box appears, follow these steps:
210
221
211
-
1. In the **Call an Azure function** action box, follow these steps:
222
+
1.From the **Method** list, select the HTTP method required to call the selected function.
212
223
213
-
1. For **Method**, select the HTTP method required to call the selected function.
224
+
1. For **Request Body**, provide your function's input, which must use the format for a JavaScript Object Notation (JSON) object, for example:
214
225
215
-
1. For **Request Body**, provide your function's input, which must be formatted as a JavaScript Object Notation (JSON) object. This input is the *context object* payload or message that your workflow sends to your function.
226
+
`{"context": <selected-input> }`
227
+
228
+
This input is the *context object* payload or message that your workflow sends to your function.
216
229
217
230
- To select tokens that represent outputs from previous steps, select inside the **Request Body** box, and then select the option to open the dynamic content list (lightning icon).
218
231
219
232
- To create an expression, select inside the **Request Body** box, and then select option to open the expression editor (formula icon).
220
233
221
-
The following example specifies the following values:
222
-
223
-
- **Method**: **GET**
224
-
- **Request Body**: A JSON object with the **`content`** attribute and a token representing the **From** output from the email trigger.
234
+
The following example specifies a JSON object with the **`content`** attribute and a token representing the **From** output from the email trigger as the **Request Body** value:
225
235
226
-
:::image type="content" source="media/call-azure-functions-from-workflows/function-request-body-example-standard.png" alt-text="Screenshot shows Standard workflow and a function with a Request Body example for the context object payload." lightbox="media/call-azure-functions-from-workflows/function-request-body-example-standard.png":::
236
+
:::image type="content" source="media/call-azure-functions-from-workflows/function-request-body-example-standard.png" alt-text="Screenshot shows Standard workflow and a function with a Request Body example for the context object payload.":::
227
237
228
238
Here, the context object isn't cast as a string, so the object's content gets added directly to the JSON payload. Here's the complete example:
229
239
230
-
:::image type="content" source="media/call-azure-functions-from-workflows/request-body-example-complete.png" alt-text="Screenshot shows Standard workflow and a function with a complete Request Body example for the context object payload." lightbox="media/call-azure-functions-from-workflows/request-body-example-complete.png":::
240
+
:::image type="content" source="media/call-azure-functions-from-workflows/request-body-example-complete.png" alt-text="Screenshot shows Standard workflow and a function with a complete Request Body example for the context object payload.":::
231
241
232
242
If you provide a context object other than a JSON token that passes a string, a JSON object, or a JSON array, you get an error. However, you can cast the context object as a string by enclosing the token in quotation marks (**""**), for example, if you wanted to use the **Received Time** token:
233
243
234
-
:::image type="content" source="media/call-azure-functions-from-workflows/function-request-body-string-cast-example.png" alt-text="Screenshot shows Standard workflow and a Request Body example that casts context object as a string." lightbox="media/call-azure-functions-from-workflows/function-request-body-string-cast-example.png":::
244
+
:::image type="content" source="media/call-azure-functions-from-workflows/function-request-body-string-cast-example.png" alt-text="Screenshot shows Standard workflow and a Request Body example that casts context object as a string.":::
235
245
236
246
1. To specify other details such as the method to use, request headers, query parameters, or authentication, open the **Advanced parameters** list, and select the parameters that you want. For authentication, your options differ based on your selected function. For more information, review [Enable authentication for functions](#enable-authentication-functions).
0 commit comments