Skip to content

Commit cfd433c

Browse files
Merge pull request #229983 from ecfan/azure-functions
Azure Logic Apps: Azure Functions - Clarity updates about managed identity and Azure AD support
2 parents 6605522 + 91393aa commit cfd433c

File tree

1 file changed

+43
-59
lines changed

1 file changed

+43
-59
lines changed

articles/logic-apps/logic-apps-azure-functions.md

Lines changed: 43 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,37 @@ services: logic-apps
55
ms.suite: integration
66
ms.reviewer: estfan, azla
77
ms.topic: how-to
8-
ms.date: 02/14/2022
8+
ms.date: 03/07/2023
99
ms.custom: devx-track-js
1010
---
1111

1212
# Create and run code from workflows in Azure Logic Apps using Azure Functions
1313

14-
[!INCLUDE [logic-apps-sku-consumption](../../includes/logic-apps-sku-consumption.md)]
14+
[!INCLUDE [logic-apps-sku-consumption-standard](../../includes/logic-apps-sku-consumption-standard.md)]
1515

1616
When you want to run code that performs a specific job in your logic app workflow, you can create a function by using [Azure Functions](../azure-functions/functions-overview.md). This service helps you create Node.js, C#, and F# functions so you don't have to build a complete app or infrastructure to run code. Azure Functions provides serverless computing in the cloud and is useful for performing certain tasks, for example:
1717

1818
* Extend your logic app's behavior with functions in Node.js or C#.
1919
* Perform calculations in your logic app workflow.
2020
* Apply advanced formatting or compute fields in your logic app workflows.
2121

22-
> [!NOTE]
23-
> Azure Logic Apps doesn't support using Azure Functions with deployment slots enabled. Although this scenario might sometimes work,
24-
> this behavior is unpredictable and might result in authorization problems when your workflow tries call the Azure function.
22+
This how-to guide shows how to call an Azure function from a logic app workflow. To run code snippets without using Azure Functions, review [Add and run inline code](logic-apps-add-run-inline-code.md). To call and trigger a logic app workflow from inside a function, the workflow must start with a trigger that provides a callable endpoint. For example, you can start the workflow with the **HTTP**, **Request**, **Azure Queues**, or **Event Grid** trigger. Inside your function, send an HTTP POST request to the trigger's URL and include the payload you want that workflow to process. For more information, review [Call, trigger, or nest logic app workflows](logic-apps-http-endpoint.md).
23+
24+
## Limitations
25+
26+
* You can create a function directly from inside a Consumption logic app workflow, but from not a Standard logic app workflow. However, you can create functions in other ways. For more information, see [Create functions from inside logic app workflows](#create-function-designer).
27+
28+
* Only Consumption workflows support authenticating Azure function calls using a managed identity with Azure Active Directory (Azure AD) authentication. Standard workflows aren't currently supported in the section about [how to enable authentication for function calls](#enable-authentication-functions).
2529

26-
This article shows how to call an Azure function from a logic app workflow. To run code snippets without using Azure Functions, review [Add and run inline code](logic-apps-add-run-inline-code.md). To call and trigger a logic app workflow from inside a function, the workflow must start with a trigger that provides a callable endpoint. For example, you can start the workflow with the **HTTP**, **Request**, **Azure Queues**, or **Event Grid** trigger. Inside your function, send an HTTP POST request to the trigger's URL and include the payload you want that workflow to process. For more information, review [Call, trigger, or nest logic app workflows](logic-apps-http-endpoint.md).
30+
* Azure Logic Apps doesn't support using Azure Functions with deployment slots enabled. Although this scenario might sometimes work, this behavior is unpredictable and might result in authorization problems when your workflow tries call the Azure function.
2731

2832
## Prerequisites
2933

3034
* Azure account and subscription. If you don't have a subscription, [sign up for a free Azure account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
3135

3236
* An Azure function app resource, which is a container for a function that you can create using Azure Functions, along with the function that you want to use.
3337

34-
If you don't have a function app, [create your function app first](../azure-functions/functions-get-started.md). You can then create your function either outside your logic app in the Azure portal or [from inside your logic app](#create-function-designer) in the workflow designer.
38+
If you don't have a function app, [create your function app first](../azure-functions/functions-get-started.md). You can then create your function either outside your logic app workflow by using Azure Functions in the Azure portal or [from inside your logic app workflow](#create-function-designer) in the designer.
3539

3640
* When you work with logic app resources, the same requirements apply to both function apps and functions, existing or new:
3741

@@ -47,9 +51,7 @@ This article shows how to call an Azure function from a logic app workflow. To r
4751

4852
* If you have an OpenAPI definition for your function, the workflow designer gives you a richer experience when your work with function parameters. Before your logic app workflow can find and access functions that have OpenAPI definitions, [set up your function app by following these later steps](#function-swagger).
4953

50-
* Either a [Consumption or Standard](logic-apps-overview.md#resource-environment-differences) logic app resource and workflow where you want to use the function.
51-
52-
Before you can add an action that runs a function in your workflow, the workflow must start with a trigger as the first step. If you're new to logic app workflows, review [What is Azure Logic Apps](logic-apps-overview.md) and [Quickstart: Create your first logic app workflow](quickstart-create-first-logic-app-workflow.md).
54+
* To follow the example in this how-to guide, you'll need a [Consumption logic app resource](logic-apps-overview.md#resource-environment-differences) and workflow that has a trigger as the first step. Although you can use any trigger for your scenario, this example uses the Office 365 Outlook trigger named **When a new email arrives**.
5355

5456
<a name="function-swagger"></a>
5557

@@ -100,16 +102,18 @@ Now that you've created your function in Azure, follow the steps to [add functio
100102

101103
<a name="create-function-designer"></a>
102104

103-
## Create functions from inside logic app workflows
105+
## Create functions from inside logic app workflows (Consumption workflows only)
104106

105-
You can create functions directly from your logic app's workflow by using the built-in Azure Functions action in the workflow designer, but you can use this method only for functions written in JavaScript. For other languages, you can create functions through the Azure Functions experience in the Azure portal. However, before you can create your function in Azure, you must already have a function app resource, which is a container for your functions. If you don't have a function app, create that function app first. For more information, review [Create your first function in the Azure portal](../azure-functions/functions-get-started.md).
107+
You can create functions directly from inside your Consumption workflow by using the built-in Azure Functions action in the workflow designer, but you can use this method only for functions written in JavaScript. For other languages, you can create functions through the Azure Functions experience in the Azure portal. However, before you can create your function in Azure, you must already have a function app resource, which is a container for your functions. If you don't have a function app, create that function app first. For more information, review [Create your first function in the Azure portal](../azure-functions/functions-get-started.md).
106108

107-
> [!NOTE]
108-
> Currently, you can only create a function directly from a Consumption logic app workflow, not a Standard logic app workflow.
109-
> However, you can create the function in other ways using the [Azure portal](../azure-functions/functions-create-function-app-portal.md),
110-
> [Visual Studio](../azure-functions/functions-create-your-first-function-visual-studio.md), [Visual Studio Code](../azure-functions/create-first-function-vs-code-csharp.md),
111-
> [Azure CLI](/cli/azure/functionapp/app), [Azure PowerShell](/powershell/module/az.functions), or [ARM template](/azure/templates/microsoft.web/sites/functions).
112-
> You can then call that function from your Standard logic app workflow using the Azure Functions operation named **Call an Azure function**.
109+
Standard workflows currently don't support this option for creating a function from within a workflow, but you can create the function in the following ways and then [call that function from your Standard logic app workflow using the Azure Functions operation named **Call an Azure function**](#add-function-logic-app).
110+
111+
* [Azure portal](../azure-functions/functions-create-function-app-portal.md)
112+
* [Visual Studio](../azure-functions/functions-create-your-first-function-visual-studio.md)
113+
* [Visual Studio Code](../azure-functions/create-first-function-vs-code-csharp.md)
114+
* [Azure CLI](/cli/azure/functionapp/app)
115+
* [Azure PowerShell](/powershell/module/az.functions)
116+
* [ARM template](/azure/templates/microsoft.web/sites/functions)
113117

114118
1. In the [Azure portal](https://portal.azure.com), open your Consumption logic app workflow in the designer.
115119

@@ -163,7 +167,7 @@ You can create functions directly from your logic app's workflow by using the bu
163167

164168
<a name="add-function-logic-app"></a>
165169

166-
## Add existing functions to logic app workflows
170+
## Add existing functions to logic app workflows (Consumption + Standard workflows)
167171

168172
To call existing functions from your logic app workflow, you can add functions like any other action in the workflow designer.
169173

@@ -173,7 +177,9 @@ To call existing functions from your logic app workflow, you can add functions l
173177

174178
1. Under the step where you want to add the function, select **New step**.
175179

176-
1. Under **Choose an action**, in the search box, enter `azure functions`. From the actions list, select the action named **Choose an Azure function**, for example:
180+
1. Under the **Choose an operation** search box, select **All**. In the search box, enter **azure functions**.
181+
182+
1. From the actions list, select the action named **Choose an Azure function**, for example:
177183

178184
![Screenshot showing Azure portal for Consumption logic app workflow and designer with the search box to find Azure functions.](./media/logic-apps-azure-functions/find-azure-functions-action-consumption.png)
179185

@@ -203,9 +209,9 @@ To call existing functions from your logic app workflow, you can add functions l
203209

204210
1. On the designer, either under the last step or between existing steps in your workflow, select the plus (**+**) sign for **Insert a new step**, and then select **Add an action**.
205211

206-
1. Under the **Choose an operation** search box, select **Built-in** if not selected.
212+
1. Under the **Choose an operation** search box, select **Built-in**. In the **Choose an operation** search box, enter **azure function**.
207213

208-
1. In the **Choose an operation** search box, enter `azure function`. From the actions list, select the action named **Call an Azure function**, for example:
214+
1. From the actions list, select the action named **Call an Azure function**, for example:
209215

210216
![Screenshot showing the Azure portal for Standard logic app workflow and the designer with the search box to find Azure functions.](./media/logic-apps-azure-functions/find-azure-functions-action-standard.png)
211217

@@ -229,16 +235,20 @@ To call existing functions from your logic app workflow, you can add functions l
229235

230236
<a name="enable-authentication-functions"></a>
231237

232-
## Enable authentication for function calls
238+
## Enable authentication for function calls (Consumption workflows only)
233239

234-
To authenticate access to resources protected by Azure Active Directory (Azure AD), your logic app can use a [managed identity](../active-directory/managed-identities-azure-resources/overview.md) (formerly known as Managed Service Identity or MSI). This managed identity can authenticate access without having to sign in and provide credentials or secrets. Azure manages this identity for you and helps secure your credentials because you don't have to provide or rotate secrets. You can set up the system-assigned identity or a manually created, user-assigned identity on your logic app. The function that's called from your workflow can use the same identity for authentication.
240+
Your Consumption workflow can authenticate function calls and access to resources protected by Azure Active Directory (Azure AD) by using a [managed identity](../active-directory/managed-identities-azure-resources/overview.md) (formerly known as Managed Service Identity or MSI). This managed identity can authenticate access without having to sign in and provide credentials or secrets. Azure manages this identity for you and helps secure your credentials because you don't have to provide or rotate secrets. You can set up the system-assigned identity or a manually created, user-assigned identity at the logic app resource level. The function that's called from your workflow can use the same identity for authentication.
241+
242+
> [!NOTE]
243+
>
244+
> Currently, only Consumption workflows support authentication for Azure function calls using a managed identity and Azure Active Directory (Azure AD) authentication. Standard workflows currently don't include this support when using the Azure Functions connector.
235245
236246
For more information, review the following documentation:
237247

238248
* [Authenticate access with managed identities](create-managed-service-identity.md)
239249
* [Add authentication to outbound calls](logic-apps-securing-a-logic-app.md#add-authentication-outbound)
240250

241-
To set up your function app and function so they can use your logic app's managed identity, follow these high-level steps:
251+
To set up your function app and function so they can use your Consumption logic app's managed identity, follow these high-level steps:
242252

243253
1. [Enable and set up your logic app's managed identity](create-managed-service-identity.md).
244254

@@ -250,9 +260,9 @@ To set up your function app and function so they can use your logic app's manage
250260

251261
<a name="set-authentication-function-app"></a>
252262

253-
## Set up your function for anonymous authentication
263+
### Set up your function for anonymous authentication (Consumption workflows only)
254264

255-
For your function to use your logic app's managed identity, you must set your function's authentication level to anonymous. Otherwise, your logic app workflow throws a **BadRequest** error.
265+
For your function to use your Consumption logic app's managed identity, you must set your function's authentication level to anonymous. Otherwise, your workflow throws a **BadRequest** error.
256266

257267
1. In the [Azure portal](https://portal.azure.com), find and select your function app.
258268

@@ -284,7 +294,7 @@ For your function to use your logic app's managed identity, you must set your fu
284294

285295
<a name="find-required-values"></a>
286296

287-
## Find the required values to set up Azure AD authentication
297+
### Find the required values to set up Azure AD authentication (Consumption workflows only)
288298

289299
Before you can set up your function app to use Azure AD authentication, you need to find and save the following values by following the steps in this section.
290300

@@ -293,13 +303,9 @@ Before you can set up your function app to use Azure AD authentication, you need
293303

294304
<a name="find-object-id"></a>
295305

296-
### Find the object ID for your logic app's managed identity
297-
298-
Based on the whether you have a Consumption or Standard logic app resource, follow the respective steps:
299-
300-
#### [Consumption](#tab/consumption)
306+
#### Find the object ID for your logic app's managed identity
301307

302-
1. After your logic app has its managed identity enabled, on the logic app menu, under **Settings**, select **Identity**, and then select either **System assigned** or **User assigned**.
308+
1. After your Consumption logic app has its managed identity enabled, on the logic app menu, under **Settings**, select **Identity**, and then select either **System assigned** or **User assigned**.
303309

304310
* **System assigned**
305311

@@ -317,31 +323,9 @@ Based on the whether you have a Consumption or Standard logic app resource, foll
317323

318324
![Screenshot showing the user-assigned identity's "Overview" pane with the object ID selected.](./media/logic-apps-azure-functions/user-identity-object-id.png)
319325

320-
#### [Standard](#tab/standard)
321-
322-
1. After your logic app has its managed identity enabled, on the logic app menu, under **Settings**, select **Identity**, and then select either **System assigned** or **User assigned**.
323-
324-
* **System assigned**
325-
326-
For the system-assigned identity, copy the identity's object ID, for example:
327-
328-
![Screenshot showing the Standard logic app "Identity" pane with the "System assigned" tab selected.](./media/logic-apps-azure-functions/system-identity-standard.png)
329-
330-
* **User assigned**
331-
332-
1. For the user-assigned identity, select the identity to find the object ID, for example:
333-
334-
![Screenshot showing the Standard logic app "Identity" pane with the "User assigned" tab selected.](./media/logic-apps-azure-functions/user-identity-standard.png)
335-
336-
1. On the managed identity's **Overview** pane, you can find the identity's object ID, for example:
337-
338-
![Screenshot showing the user-assigned managed identity's "Overview" pane with the object ID selected.](./media/logic-apps-azure-functions/user-identity-object-id.png)
339-
340-
---
341-
342326
<a name="find-tenant-id"></a>
343327

344-
### Find the tenant ID for your Azure AD
328+
#### Find the tenant ID for your Azure AD
345329

346330
To find your Azure AD tenant ID, either run the PowerShell command named [**Get-AzureAccount**](/powershell/module/servicemanagement/azure.service/get-azureaccount), or in the Azure portal, follow these steps:
347331

@@ -355,9 +339,9 @@ To find your Azure AD tenant ID, either run the PowerShell command named [**Get-
355339

356340
<a name="create-app-registration"></a>
357341

358-
## Create app registration for your function app
342+
### Create app registration for your function app (Consumption workflows only)
359343

360-
After you find the object ID for your logic app's managed identity and tenant ID for your Azure AD, you can set up your function app to use Azure AD authentication by creating an app registration. For more information, review [Configure your App Service or Azure Functions app to use Azure AD login](../app-service/configure-authentication-provider-aad.md#-step-2-enable-azure-active-directory-in-your-app-service-app).
344+
After you find the object ID for your Consumption logic app's managed identity and tenant ID for your Azure AD, you can set up your function app to use Azure AD authentication by creating an app registration. For more information, review [Configure your App Service or Azure Functions app to use Azure AD login](../app-service/configure-authentication-provider-aad.md#-step-2-enable-azure-active-directory-in-your-app-service-app).
361345

362346
1. In the [Azure portal](https://portal.azure.com), open your function app.
363347

0 commit comments

Comments
 (0)