Tutorial: Create approval-based workflows using Azure Logic Apps
Article
Applies to: Azure Logic Apps (Consumption)
This tutorial shows how to build an example workflow that automates an approval-based task by using Azure Logic Apps. This example specifically creates a Consumption logic app workflow that processes subscription requests for a mailing list that's managed by MailChimp.
The workflow starts with monitoring an email account for requests, sends received requests for approval, checks whether or not the request gets approval, adds approved members to the mailing list, and confirms whether or not new members get added to the list.
When you finish, your workflow looks like the following high level example:
Tip
To learn more, you can ask Azure Copilot these questions:
What's Azure Logic Apps?
What's a Consumption logic app workflow?
To find Azure Copilot, on the Azure portal toolbar, select Copilot.
You can create a similar workflow with a Standard logic app resource where some connector operations, such as Azure Blob Storage, are also available as built-in, service provider-based operations. However, the user experience and tutorial steps vary slightly from the Consumption version.
A MailChimp account where you previously created a list named "test-members-ML" where your logic app can add email addresses for approved members. If you don't have an account, sign up for a free account, and then learn how to create a MailChimp list.
An email account in Office 365 Outlook or Outlook.com, which supports approval workflows. For other email providers, see Connectors for Azure Logic Apps.
This tutorial uses Office 365 Outlook with a work or school account. If you use a different email account, the general steps stay the same, but the user experience might slightly differ. If you use Outlook.com, use your personal Microsoft account instead to sign in.
If your logic app workflow needs to communicate through a firewall that limits traffic to specific IP addresses, that firewall needs to allow access for both the inbound and outbound IP addresses used by Azure Logic Apps in the Azure region where your logic app resource exists. If your logic app also uses managed connectors, such as the Office 365 Outlook connector or SQL connector, or uses custom connectors, the firewall also needs to allow access for all the managed connector outbound IP addresses in your logic app's Azure region.
Create a Consumption logic app resource
In the Azure portal, sign in with your Azure account.
In the Azure portal search box, enter logic app, and select Logic apps.
On the Logic apps page toolbar, select Add.
The Create Logic App page appears and shows the following options:
Plan
Description
Consumption
Creates a logic app resource that supports only one workflow that runs in multitenant Azure Logic Apps and uses the Consumption model for billing.
Standard
Creates a logic app resource that supports multiple workflows. You have the following options:
- Workflow Service Plan: Workflows run in single-tenant Azure Logic Apps and use the Standard model for billing.
On the Create Logic App page, select Consumption (Multi-tenant).
On the Basics tab, provide the following information about your logic app resource:
Property
Required
Value
Description
Subscription
Yes
<Azure-subscription-name>
Your Azure subscription name.
This example uses Pay-As-You-Go.
Resource Group
Yes
<Azure-resource-group-name>
The Azure resource group where you create your logic app and related resources. This name must be unique across regions and can contain only letters, numbers, hyphens (-), underscores (_), parentheses (()), and periods (.).
This example creates a resource group named LA-MailingList-RG.
Logic App name
Yes
<logic-app-resource-name>
Your logic app resource name, which must be unique across regions and can contain only letters, numbers, hyphens (-), underscores (_), parentheses (()), and periods (.).
This example creates a logic app resource named LA-MailingList.
Region
Yes
<Azure-region>
The Azure datacenter region for your app.
This example uses West US.
Enable log analytics
Yes
No
Change this option only when you want to enable diagnostic logging. For this tutorial, keep the default selection.
Note: This option is available only with Consumption logic apps.
The Office 365 Outlook connector requires that you sign in with a Microsoft work or school account. If you're using a personal Microsoft account, use the Outlook.com connector.
Sign in to your email account, which creates a connection between your workflow and your email account.
In the trigger information box, from the Advanced parameters list, add the following parameters, if they don't appear, and provide the following information:
Parameter
Value
Description
Importance
Any
Specifies the importance level of the email that you want.
Folder
Inbox
The email folder to check.
Subject Filter
subscribe-test-members-ML
Specifies the text to find in the email subject and filters emails based on the subject line.
Note
When you select inside some edit boxes, the options for the dynamic content list (lightning icon)
and expression editor (function icon) appear, which you can ignore for now.
On the Condition action pane, rename the action with If request approved.
Build a condition that checks whether the approver selected Approve.
On the Parameters tab, in the first row under the AND list, select inside the left box, and then select the dynamic content list (lightning icon). From this list, in the Send approval email section, select the SelectedOption output.
In the middle box, keep the operator named is equal to.
In the right box, enter Approve.
When you finish, the condition looks like the following example:
Save your workflow.
Add an action to include member in MailChimp list
The following steps add an action that includes the approved member on your mailing list.
When you finish, the Add member to list action looks like the following example:
Save your workflow.
Add an action to check success or failure
The following steps add a condition to check whether the new member successfully joined your mailing list. Your workflow can then notify you whether this operation succeeded or failed.
Rename the condition with If add member succeeded.
Build a condition that checks whether the approved member succeeds or fails in joining your mailing list.
On the Parameters tab, in the first row under the AND list, select inside the left box, and then select the dynamic content list (lightning icon). From this list, in the Add member to list section, select the Status output.
In the middle box, keep the operator named is equal to.
In the right box, enter subscribed.
When you finish, the condition looks like the following example:
Add an action to send success email
The following steps add an action to send success email when the workflow succeeds in adding the member to your mailing list.
Rename the Send an email action with Send email on failure.
In the Send email on failure action, provide the following information:
Parameter
Required
Value
Description
To
Yes
<recipient-email-address>
The email recipient's email address. For testing purposes, use your own email address.
Subject
Yes
<failure-email-subject>
The subject for the failure email. For this example, follow these steps:
1. Enter the following text with a trailing space: Failed, member not added to test-members-ML:
2. Select inside the Subject box, and select the dynamic content list option (lightning icon).
3. From the Add member to list section, select Email Address.
Note: If this output doesn't appear, next to the Add member to list section name, select See more.
Body
Yes
<failure-email-body>
The body content for the failure email.
For this example, enter the following text: Member might already exist. Check your MailChimp account.
When you finish, the action looks like the following example:
Save your workflow.
Your finished workflow looks similar to the following example:
Test your workflow
Send yourself an email request to join your mailing list. Wait for the request to appear in your inbox.
To manually start your workflow, on the designer toolbar, select Run > Run.
If your email has a subject that matches the trigger's subject filter, your workflow sends you email to approve the subscription request.
In the approval email that you receive, select Approve.
If the subscriber's email address doesn't exist on your mailing list, your workflow adds that person's email address and sends you an email like the following example:
If your workflow can't add the subscriber, you get an email like the following example:
Tip
If you don't get any emails, check your email's junk folder. Otherwise,
if you're unsure that your logic app ran correctly, see
Troubleshoot your logic app.
Congratulations, you created and ran a logic app workflow that integrates information across Azure, Microsoft services, and other SaaS apps!
Clean up resources
Your workflow continues running until you disable or delete the logic app resource. When you no longer need this sample, delete the resource group that contains your logic app and related resources.
Your workflow continues running until you disable or delete the logic app resource. When you no longer need this sample, delete the resource group that contains your logic app and related resources.
In the Azure portal search box, enter resource groups, and select Resource groups.
From the Resource groups list, select the resource group for this tutorial.
On the resource group menu, select Overview.
On the Overview page toolbar, select Delete resource group.
When the confirmation pane appears, enter the resource group name, and select Delete.
Next steps
In this tutorial, you created a logic app workflow that handles approvals for mailing list requests. Now, learn how to build a logic app workflow that processes and stores email attachments by integrating Azure services, such as Azure Storage and Azure Functions.