Azure App Service Introduction Series – Logic Apps

Unlike Web Apps and API Apps which are basically containers where you deploy your web and API apps, Logic Apps allow us to build workflows by orchestrating a set of actions, such as calling APIs, consuming/update data, sending emails, and so on.

To perform actions, Logic Apps use connectors to connect to and consume resources that might or might not live inside Azure; for example API Apps, on premise APIs, Azure Blob Storage, SQL Azure, Azure SaaS such as SharePoint and Exchange Online and so on, in addition to other Logic Apps (hence creating composite orchestrations).

So why Logic Apps? Simply for anytime you want a workflow (i.e. business logic) to run in Azure that might perform any composite business function that you want. For example when a certain event occurs (for example a new order is placed) (called a trigger), you can have a Logic App that sends an email (an action), calls a log API (another action), checks a certain ERP store (action) and based on the result (a condition) updates a CRM SaaS (an action), and so on…

There are connectors for various use cases:

  • API Apps
  • Logic Apps
  • Azure Functions
  • SQL Azure
  • SaaS such as Office 365
  • Third party connectors created by vendors who want their resources to be consumed by Logic Apps (ex: SAP, Oracle, etc…)

If you know about BizTalk Server, these are similar to the concept of Adapters. They also provide reliability as they automatically retry in case of communication failure.

Triggers starts a Logic App – or more specifically an instance of a Logic App (You create a Logic App using the definition language – it acts as a template and each trigger kicks in a new instance). Triggers can be:

  • Timers (for example start every 15 minutes)
  • Connectors can also act as a trigger – for example upon receiving a new order. So a common question here: say I receive a lot of orders at the same time? No problem, multiple instances will run in parallel, but the number of instanced is limited by the pricing tier

You write Logic Apps by using the Logic Apps Definition Language which is JSON-based. Logic Apps provide templates to start with; these cover some common orchestration scenarios.

Before we start, let’s install an extension required to be able to edit our Logic App in VS designer (instead of editing JSON directly):

1

Now let’s start creating the most dump workflow ever, by creating a new Resource Group from VS 2015:

2

Then select the Logic App template:

3

You will then have a new project created. Open the [name].json file using the extension we installed at the beginning:

4

You will be asked to supply the Azure account credentials, as VS will connect to Azure to download the templates:

5

What you then get is the designer, with a set of templates to start with, in addition to the option of creating a new one. Let’s select the option to create a new blank app:

6

The first thing you have to do is to create a trigger for the Logic App. In this case I simply select Recurrence, which means the app will start using a timer:

7

Here is what we end up with:

8

Next I want to call the API App that we created before, so select “Add an action” and in the resulting window select HTTP+Swagger to call that API using the Swagger metadata:

9

Here we supply the Swagger metadata of the API we created before:

10

Since we’re using Swagger, we get the nice UI support and then we can select the verb we want to call, in this case the Get over our values resource:

11

In the next action, I want to send the result of the GET request to an email, so select the send email action:

12

Here we supply the required information to the send email action, and as you can we can select to send the result of the GET request as the body of the email:

13

Now we’re ready to deploy the Logic App. You can either select an existing Resource Group (as I did below) or create a new one:

14

15

And finally you can see the Logic App deployed in Azure portal:

16

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s