Cognitive Services in Microsoft Azure

Manish
4 min readMar 31, 2019

--

What is Azure Cognitive Services and how do I actually use the service in my application?

Microsoft Azure is a collection of cloud services that help your organization meet your day to day challenges providing you the capability to build, manage and deploy applications on massive, global networks using favorite frameworks.

Among the various services Azure provides, cognitive services allow you to harness the power of machine learning and integrate advanced intelligence into your product.

The collection of APIs provides users with services such as:

  • image processing algorithms
  • convert spoken audio into text with high accuracy
  • intelligent recommendations and semantic searches
  • process natural language and recognize, evaluate the user’s semantics
  • anomaly detection capabilities
  • add bing search API

We’ll cover all the services that you get through Microsoft Azure, but let’s start with one. I’ll choose the vision API that allows you to use image-processing algorithms to smartly identify, caption, index and moderate your pictures and videos.

Let’s create a simple application to harness the strong capability of Azure’s Cognitive Services.

To get started, you need to create an Azure account, which has a free trial for 12 months. To learn more and get started, get to the Azure Website.

After you create your Azure subscription. You can head over to Microsoft Azure’s portal. Then If you follow the following steps, you’ll create an API key that you can use it in your program.

If you click on the create resource and then search for Face API then you will get the Face API of cognitive services that Azure provides.

Then you need to fill in the details like the name of your resource, the subscription, the location of the data center (this should be as close to your location for faster service), pricing tier (there are two options and you can choose any option based on the usage of your API) and the resource group, which is a container for your resource to run on.

Once the resource is created, the dashboard should show the resource you create. If you click on the created resource then you’ll get to a page that shows the possible ways to use the resources.

Once on that page, you would see the various way to use the resource. You can use any resource based on the preference, but for the purpose of this article, we will grab the API keys and use them in our application.

'use strict';const request = require('request');const subscription_key = < insert your subscription key here >;const uriBase = 'https://westcentralus.api.cognitive.microsoft.com/face/v1.0/detect';const imageUrl ='https://qph.fs.quoracdn.net/main-qimg-a11587651779e9e98f1f441604ef4176';
const params = {
'returnFaceId': 'true',
'returnFaceLandmarks': 'false',
'returnFaceAttributes': 'age,gender,headPose,smile,facialHair,glasses, emotion,hair,makeup,occlusion,accessories,blur,exposure,noise'
};
const options = {
uri: uriBase,
qs: params,
body: '{"url": ' + '"' + imageUrl + '"}',
headers: {
'Content-Type': 'application/json',
'Ocp-Apim-Subscription-Key' : subscription_key
}
};
request.post(options, (error, response, body) => {
if (error) {
console.log('Error: ', error);
return;
}
let jsonResponse = JSON.stringify(JSON.parse(body), null, ' '); console.log(jsonResponse);
});

What does the code do?

There are two key things that are worthy of attention:

  • the params dictionary has a field called returnFaceAttributes that contains all the attributes you want the API to return the data on.
  • we use request to post the data created to Azure services and wait for the result, which we then print

This is how one can use a simple Face API in their application. There are definitely a lot more services that one can use based on the requirement.

Just need to Explore and Enjoy this vibrant technology — Azure.

Once you are comfortable with your skills on Azure Services, try the Azure certification Exam to get endorsed by globally recognized industry so you can showcase skills of mastery and demonstrate your abilities on new emerging technologies like Microsoft Azure.

The certification of Microsoft Certified Azure Developer Associate consists of two exams to which you can find the courses on the above link:

  • AZ-200: Developing Core Cloud Solutions
  • AZ-201: Developing Advanced Solutions

Next:

--

--