Skip to content

Commit a273c88

Browse files
author
ecfan
committed
Address customer feedback, art updates
1 parent 85d342e commit a273c88

6 files changed

+39
-29
lines changed

articles/logic-apps/call-azure-functions-from-workflows.md

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ services: logic-apps
55
ms.suite: integration
66
ms.reviewer: estfan, azla
77
ms.topic: how-to
8-
ms.date: 08/07/2024
8+
ai.usage: ai-assisted
9+
ms.date: 10/21/2024
910
---
1011

1112
# 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
8990
> The **`body`** property here applies to the **`context`** object and isn't the same as
9091
> the **Body** token in an action's output, which you might also pass to your function.
9192
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).
9394

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).
9596

9697
- A Consumption or Standard logic app workflow that starts with any trigger.
9798

@@ -103,11 +104,11 @@ This how-to guide shows how to call an existing Azure function from your Consump
103104

104105
## Tips for working with Azure functions
105106

106-
<a name="function-swagger"></a>
107+
<a name="open-ai-definition"></a>
107108

108-
### Generate an OpenAPI definition or Swagger file for your function
109+
### Find functions with OpenAPI definitions
109110

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:
111112

112113
1. In the [Azure portal](https://portal.azure.com), open your function app. Make sure that the function app is actively running.
113114

@@ -148,6 +149,16 @@ Here's what happens inside this function:
148149

149150
After you create your function in Azure, follow the steps to [add an Azure function to your workflow](#add-function-logic-app).
150151

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+
151162
<a name="add-function-logic-app"></a>
152163

153164
## 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
160171

161172
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).
162173

163-
1. In the **Create Connection** pane, follow these steps:
174+
1. In the **Add an action** pane, follow these steps:
164175

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:
166177

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.":::
168179

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:
170181

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:
172183

173-
1. In the selected function's action box, follow these steps:
184+
`{"context": <selected-input> }`
174185

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.
176187

177188
- 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).
178189

179190
- To create an expression, select inside the **Request Body** box, and then select option to open the expression editor (formula icon).
180191

181192
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:
182193

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.":::
184195

185196
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:
186197

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.":::
188199

189200
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:
190201

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.":::
192203

193204
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).
194205

@@ -202,36 +213,35 @@ To call an Azure function from your workflow, you can add that functions like an
202213

203214
1. Provide a **Connection Name** for the connection to your function app.
204215

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:
206217

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.":::
208219

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:
210221

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.
212223

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:
214225

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.
216229

217230
- 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).
218231

219232
- To create an expression, select inside the **Request Body** box, and then select option to open the expression editor (formula icon).
220233

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:
225235

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.":::
227237

228238
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:
229239

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.":::
231241

232242
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:
233243

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.":::
235245

236246
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).
237247

252 Bytes
Loading
-264 Bytes
Loading
3.87 KB
Loading
2.19 KB
Loading
2.29 KB
Loading

0 commit comments

Comments
 (0)