Logic Apps and Cognitive Services Face API – Part 1 (Middleware Friday)

This blog post covers the topic of the third session on Middleware Friday – a vLog initiative by Kent Weare brought to you by BizTalk360. In this session, Kent Weare talks about “Azure Logic Apps and Cognitive Services Face API”. This is the first part of a multi part series of episodes on this topic.

You can download the entire article as a PDF document.
Logic Apps and Cognitive Services Face API

Click here to read the second part blog of this Middleware Friday episode series on Azure Logic Apps and Cognitive Services Face API.

Cognitive Services Vision API

The Vision API is a state-of-the-art image processing algorithm that helps to moderate content automatically and build personalized apps by returning insights about faces, images and emotions. This API has several operations like Face Detection, Face Verification, Similar Face Search, Face Grouping, and Face Identification.

Demo

Let’s get started with the demo! For the demo purposes, Kent takes the example of an electronics store. I’ll try to replicate the same scenario with my examples to give you a real time experience :-). A security CCTV camera captures the faces of the shoppers who come in to the store. Once the pictures are taken, they are uploaded on to OneDrive. A Logic App consumes these images from OneDrive that will further be uploaded on to a Blob Storage. We will retrieve the URI that can be passed to the Cognitive Services Face API (by providing a public URI/URL that the Face API can pull from). The Face API will return a series of attributes that we will be storing on SQL Azure.

Demo Scenario

Create a Cognitive Services Account

Prerequisite: You need to create a Cognitive Services Account in Microsoft Azure before getting started with using the Face API feature.

  1. Sign in to the Azure Portal and navigate to ‘Cognitive Services
  2. Enter your Account Name
  3. Choose your Azure Subscription
  4. Select the API Type (in this case Face API)
  5. Choose your Location
  6. Choose your preferred pricing tier – F0 (20 calls per minute, 30K calls per month) or S0 (10 calls per second). Let’s choose the Free Tier (F0) for our purpose.
  7. Choose the Resource Group
  8. Agree to the terms and conditions and create your Cognitive Services account

Cognitive Services - Account Creation

You can download the entire article as a PDF document.
Logic Apps and Cognitive Services Face API

Creating the Face API Logic App

The next step is to create the Face API Logic App. We will create a Logic App with the name MF-FaceAPI. Once the Logic App is created, in the Logic App Designer, let’s start off with a Blank Logic App.

  1. We will first create a trigger for the file drop on OneDrive
    Cognitive Services - Create Logic App
  2. In the next step, we will create an action where the files from OneDrive are uploaded on to the blob storage. If you do not have a blob storage, you need to first create an Azure Storage account. In the ‘Create Blob’ connector, first connect with your Storage Account, and then provide the folder path, blob name, and blob content.
    Cognitive Services - Create Blob
  3. Next, create an action to call the ‘Detect Faces (Preview)‘ API.  For the purpose of this demo, we are simply taking the URL of the blob storage as the input so that the Face API can identify the pictures in the storage.
    Cognitive Services - Create Face API Action
  4. In the last step, we will create a ‘For Each‘ action for the Face API operation that it will report the demographics information about the person in the picture to the Demographics table in the database. In this case, we will use SQL Azure. Therefore, you need to create a SQL Azure database first and then create a table with the following fields – ID, Gender, Age, Mustache, Beard, Sideburns, Sunglasses. The reason we are creating these database fields is that our Vision API will scan the picture to see if the person in the photo has any of these parameters and report the status into the database.
    Cognitive Services - For Each Photo Database Entry
  5. That’s it! We have now created our Logic App. Time to run it and watch the fun :-). I am showing the real time execution of this Logic App that we created in the below recording fileLogic Apps Video recording (Original)
    Definitely takes less than a minute to identify your facial features and report the data to a SQL database. Interesting right? Then, hold on! There’s more coming in the next blog post as well. Kent also highlighted the community content from Steef-Jan Wiggers on “Using Azure Service Bus and BizTalk 2016 for messaging between enterprises“. You can watch the video of this session on Azure Logic Apps and Cognitive Services here.

 

Feedback

You can give your feedback about Middleware Friday episodes, any special topic of interest, or any guest speaker whom you would like to see at Middleware Friday. Simply tweet at @MiddlewareFri or drop an email to middlewarefriday@gmail.com.

You can watch the Middleware Friday sessions here.

You can download the entire article as a PDF document.
Logic Apps and Cognitive Services Face API
Author: Sriram Hariharan

Sriram Hariharan is the Senior Technical and Content Writer at BizTalk360. He has over 9 years of experience working as documentation specialist for different products and domains. Writing is his passion and he believes in the following quote - “As wings are for an aircraft, a technical document is for a product — be it a product document, user guide, or release notes”.

  • Varun Dubey

    Tried the above example, the execution errors out at Face API, saying it could not find the resource, i hardcoded it with a URL of a publicly available image on the web, it still errors out saying resource not found.

One Platform Operations, Monitoring and Analytics Software
BizTalk360

microsoft biztalk

Learn more

Over 500 customers across 30+ countries depend on BizTalk360

ServiceBus360

Azure service bus

Learn more

Start managing your Azure Service Bus namespaces in minutes

One Platform - Operations, Monitoring and Analytics Software
BizTalk360

microsoft biztalk

Learn more

Over 500 customers across 30+ countries depend on BizTalk360

One Platform - Operations, Monitoring and Analytics Software
ServiceBus360

Azure service bus

Learn more

Start managing your Azure Service Bus namespaces in minutes

Back to Top