Skip to main content
Introduction

You may be familiar with ifttt.com, a Software-as-a-Service (SaaS) solution to creating workflows. For example, you can design workflows in ifttt.com that will tweet to you where there’s a new post at your favorite blog, or automatically save all Gmail attachments to Google Drive, or the like.

Microsoft Azure has a similar service, called Logic Apps. Logic Apps are intended to make building corporate workflows as simple as ifttt.com workflows, using the same idea of chaining together triggering events, inputs and outputs.

In this guide, we are going to create a Logic App that monitors our website. We’ll send out a probe every 15 minutes to an endpoint. Whenever the webserver responds to that probe with a 400 or greater HTTP status code, we are going to:

  • Send an email to the engineering team, letting them see the status code we got back, and attaching the HTTP response as a file to the email;
  • Put a message onto a Slack channel, noting the status code we got back from the probe; and
  • Send a tweet out, letting our users know that our site is having problems and we’re fixing it.
Getting Started
To follow along with this guide, you will need a Gmail account, Slack account and / or Twitter account. You may skip each step that uses these accounts if you don’t have one, but you will need at least one of those accounts.

Create the Logic App

To begin, log in to the Azure Portal. From the left-hand blade, click New > Web + Mobile > Logic App.

user_54417_592309d1a7fdf.png

In the configuration blade that comes up, provide a name for the Logic App. This name will become the subdomain name for your Logic App, so it can only consist of letters, numbers and dashes.

Choose the appropriate subscription and resource group, then select a location.

user_54417_59230ad335d22.png

Finally, click the Create button.

Add the HTTP probe

Once the Logic App is created, click on its link. You will now be in the Logic App Designer.

user_54417_592323b7137a9.png

Scroll down until you see the Blank Logic App template and click it. This will put you into a new Logic App Designer, and you will be asked to select a service or trigger. Click the “See more” link under services.

user_54417_592324cf4ea38.png

Now scroll down until you see HTTP within the services, and click that button.

user_54417_5923253980d43.png

You will see three trigger options available. We want the plain HTTP trigger, at the top. Click that.

user_54417_592325fab213d.png

Now, we’re ready to configure the probe.

  • For Method, choose GET.
  • For Uri, enter the endpoint you want to probe. For general website availablility, that would be your site root, e.g., http://www.mysite.com
  • Leave Frequency set to Minutes and change Interval to 15.
user_54417_592326fac8f97.png

This creates an HTTP GET request to the specified URI that takes place every 15 minutes.

Add the condition

We’re now ready to tell Logic Apps what to do when it makes this probe. To do that, click on the New Step button beneath the HTTP probe, then click Add a condition.

user_54417_5923275f67c95.png

A condition box will come up.

  • For the first box, click the predefined Status code field from the “Insert parameters from previous steps” into the box.
  • For the second, pull-down menu, choose “is greater than or equal to”
  • For the third box, enter 400.

user_54417_5923283a1db75.png

This instructs the Logic App that success will be defined as any request that receives back, from the webserver, a 4xx or 5xx status code.

Set the action steps

We have defined the “yes” condition as being a 4xx or 5xx error. Therefore, we are going to leave the “IF NO, DO NOTHING” action steps empty.

Under “IF YES, DO NOTHING,” click “Add an action.”

Add Gmail action

A panel comes up listing services and actions. Scroll through the actions list until you see “Gmail Send email” and click that.

user_54417_59232979898fb.png

You will next need to click the Sign In button so you can authorize the Logic App to access your Gmail account. Click the button, select your account (if necessary), and grant Logic Apps permission to work with Gmail.

user_54417_59233adb9c670.png

Once you have granted permission, you can configure Gmail to send your message.

user_54417_59233b0ef1704.png

The form to configure Gmail may not be ordered this way when you fill it out, but all the fields noted here will be in that form.

  • Under To, enter the recipient email address.
  • Under Attachments Content, select Body from the “Insert parameters from previous steps.”
  • Under Attachments Content-Type, enter text/html
  • Under Attachments Name, enter response.html
  • Under Body, enter an appropriate message. Include the Status code from “Insert parameters from previous steps.”
  • Under Subject, enter an appropriate subject line. I would recommend including the Status code from “Insert parameters from previous steps.”
You have successfully added the email message.


Add Slack action

To add a Slack action, click “Add an action” beneath the Gmail action and type “Slack” into the search bar. Then, click “Slack Post Message” under the Actions list.

user_54417_59233c6b9b5ed.png

Again, you will need to push a button to authorize Logic Apps to access your Slack account.
user_54417_59233cae13f3b.png
Once you have authorized Logic Apps to access Slack, you can configure the message.
  • Choose a channel where you want the message sent.
  • Include the message parameters. Do not attempt to include the body of the response in your Slack message! This will cause your message to fail and the workflow to halt. You can, however, add the status code to your message.
user_54417_59233dd9c2f6f.png
You have successfully added the Slack action.
Add Twitter action
To add the Twitter action, click “Add an action” underneath the Slack action. Then enter Twitter in the search box.
In the results that come up, select Twitter Post a tweet from the actions.
user_54417_59233e331d659.png
You will need to grant Logic Apps permission to use your Twitter account. Do so.
user_54417_59233e765c233.png
Once you have granted Logic Apps permission to use your Twitter account, you are ready to configure your tweet.
Under Tweet text, enter the message you would like people to see.
user_54417_59233ea9ebe2a.png
You have now completed the Twitter action.
Save your work and monitor workflow
Your workflow is now complete. To save it, scroll back to the top of your workflow and click the Save button.
user_54417_59233ef916965.png_800.jpg
The workflow is now saved and immediately executes. It will continue to execute every 15 minutes, until you stop or delete the workflow.
You should be dumped directly into the Logic App overview, which includes a listing of execution logs.
user_54417_59233f73415ff.png_800.jpg
Click on the log entry to see a graphical representation of how your workflow executed.
user_54417_59233f9ee6fe0.png_800.jpg
Test your workflow
This workflow is designed to be triggered in the event of a non-OK response to the HTTP probe. You can test this workflow by editing the Condition to invoke the workflow if the status code from the probe is a 1xx, 2xx or 3xx response.
  • In the Logic App’s setting blade, click the Logic App Designer link.
  • Open the Condition panel.
  • Change “is greater than or equal to” in the pull-down menu to “is less than.”
  • Save the workflow, then click Run.
Your workflow will now execute all the actions you created, assuming your webserver responds to the GET request with a 200 OK HTTP status code.
Don’t forget to immediately revert your changes!

  • In the Logic App’s setting blade, click the Logic App Designer link.
  • Open the Condition panel.
  • Change “is less than” in the pull-down menu to “is greater than or equal to”
  • Save the workflow.
If your test was successful, you should have an email:
user_54417_5923413926a58.png_800.jpg
And a Slack message:
user_54417_5923414e8fba8.png_800.jpg
And a tweet:
user_54417_592341628f92f.png
Sources / Resources

Logic Apps are considerably more powerful than this relatively simple example.

You can leverage many third-party services, called “connectors,” such as MailChimp, Facebook, Github, Zendesk, Salesforce, Pagerduty, Dropbox and more.

You can also incorporate your own, custom connectors via Web APIs.

Logic Apps are fully scriptable using JSON, and that means you can incorporate them into your build and deployment pipelines, and work with them using your current SDLC tooling.

While Logic Apps aren’t a central part of Azure certification right now, their importance will increase as time goes by, and you should expect them to be a central part of your real-world Azure solutions.

Logic Apps are based in Microsoft Azure’s App Service, a Platform as a Service (PaaS) offering. However, pricing and implementation have been removed from the App Service itself. for new Logic Apps.

Logic Apps are priced on a per-execution basis, depending on the number of times your workflows are invoked each month. The first 250,000 executions are priced at .0008 cents each.

If you use this guide as designed, you will have about 3,000 executions per month, for a cost of about $2.30 per month.

Prior to January 2017, you were able to use an App Service Plan with Logic Apps, and were granted a number of executions per day as part of those plans. That model is no longer available for new Logic Apps but is still applicable to legacy Logic Apps. However, you should expect that App Service pricing will be retired at some future point.

Comments are disabled for this guide.