Using Cognitive Service Face API with Azure Logic App

Azure Logic Apps

Logic App is a cloud-based service. It allows us to react to an event in one service (such as SharePoint online) and do something with the data from that event into another service (such as Twitter). It makes it practical and simple for business processes. The users build workflows that automatically perform some business tasks and processes across applications and services. We can connect our business-critical apps and services with Azure Logic Apps, automating workflows without writing a single line of code.

Before reading this article, please go through some important article links, mentioned below.

Face API

Here, we can detect the face in the image. Whenever you upload the images in the dropbox, the Face API detect the values like Gender, Age, Beard, Glasses, Smile etc., and store the values in the Excel file.

How to use Face API in Azure Logic App

Here, we need to connect DropBox and Onedrive for accessing Face API

Prerequisites

  • Microsoft Azure Account
  • DropBox Account
  • Microsoft OneDrive Account(Excel Sheet)

Follow the below steps to build a Workflow using a template.

Step 1

Create the Cognitive Service

Login to https://portal.azure.com/

  • In the dashboard, select "Create a resource" and click on "AI + Machine Learning". Now, choose "Face" for creating the Cognitive Service.
Using Cognitive Service Face API with Azure Logic App
  • Enter the name you want to assign to the Face API, choose the subscription and resource group where you organize the related resources, and location where your logic app would be stored and the pricing tier. Then, click on "Create".
Using Cognitive Service Face API with Azure Logic App
  • Under the Keys, you have keys for accessing the Face Detection.
Using Cognitive Service Face API with Azure Logic App

Step 2

Create the Storage Account

  • In the dashboard, select "Create a resource" and click on "Storage". Now, choose Storage account.
Using Cognitive Service Face API with Azure Logic App
  • Enter the name, subscription, Location and the Access tier. Then, click on "Create".
Using Cognitive Service Face API with Azure Logic App
  • Then create the container.
Using Cognitive Service Face API with Azure Logic App
  • Container Created
Using Cognitive Service Face API with Azure Logic App
  • Open up the container and choose properties. There we have a storage URL
Using Cognitive Service Face API with Azure Logic App

Step 3

Now, let us create the Logic App for detecting the face in the image and storing the values on the Excel Spreadsheet.

  • In the dashboard, choose to create a resource and click on Integration. Now, choose Logic App.
Using Cognitive Service Face API with Azure Logic App
  • Enter the name you want to assign to the logic, choose the subscription, resource group where you organize related resources, and location where your logic app is stored. Then, click on "Create".
Using Cognitive Service Face API with Azure Logic App
  • Here is the dashboard. Click on Logic App Designer.
Using Cognitive Service Face API with Azure Logic App

Step 4

Now, click on the Blank Logic App.

Using Cognitive Service Face API with Azure Logic App

Step 5

Configure the data by signing into DropBox and Excel Online.

  • Search DropBox on the search bar.
Using Cognitive Service Face API with Azure Logic App
  • Choose the Triggers.
Using Cognitive Service Face API with Azure Logic App
  • Next, we sign in.
Using Cognitive Service Face API with Azure Logic App
  • We give permission to access our accounts.
Using Cognitive Service Face API with Azure Logic App
  • Next, Choose Folder name where you upload the images.
Using Cognitive Service Face API with Azure Logic App

Step 6

Configure the Blob Storage

  • Search Blob Storage
Using Cognitive Service Face API with Azure Logic App
  • Choose the Storage Connection
 Using Cognitive Service Face API with Azure Logic App
  • Next, Choose the folder path, Blob name, and Blob content.
Using Cognitive Service Face API with Azure Logic App

Step 7

Configure the cognitive Face API for detecting the Face in the Image.

  • Search for Face API.
Using Cognitive Service Face API with Azure Logic App
  • Choose the Action.
Using Cognitive Service Face API with Azure Logic App
  • After that, give the Connection name, API Key and Site URL from Face API Cognitive Service.
Using Cognitive Service Face API with Azure Logic App
  • Now, enter the Blob storage link and choose the path in the image URL.
Using Cognitive Service Face API with Azure Logic App

Step 8

  • Next, we want to save that value into the Excel sheet, so search for Excel Online.
Using Cognitive Service Face API with Azure Logic App
  • Then, choose the Action for the workflow.
Using Cognitive Service Face API with Azure Logic App
  • Next, we sign in to OneDrive.
Using Cognitive Service Face API with Azure Logic App
  • We give permission to access our accounts.
Using Cognitive Service Face API with Azure Logic App
  • Next, Choose File Name and Table Name for saving the Image values. And, Then, Choose the Fields what you want
Using Cognitive Service Face API with Azure Logic App
  • The final Workflow will be like this.
Using Cognitive Service Face API with Azure Logic App

Step 6

Now we save and run the workflow and run it.

 Using Cognitive Service Face API with Azure Logic App

Output

Upload the image in the DropBox

Using Cognitive Service Face API with Azure Logic App

Now, the values are saved in Excel.

Using Cognitive Service Face API with Azure Logic App

Logic App Evaluation

Using Cognitive Service Face API with Azure Logic App

Summary

I hope you understood how to use Face API and store the values in the Excel spreadsheet automatically and how to run it. Stay tuned for more.