In this Azure tutorial, we will discuss the Azure Face API example.
Azure Face API Example
Well, here we will discuss an Implementation Of Face API Using C# in Visual Studio 2019. As part of the implementation, we will perform the below functionalities here.
- Creating Microsoft Azure Face API using the Azure Portal.
- Creating a WPF application using Visual Studio 2019 and C# to implement the Face API. As part of the implementation, It will detect the face in an image and will show a red frame around each face. also, if you mouse over the detected face in the image, it will show you all the attributes like Gender, Age, Emotion, Glasses, etc.
Well, it is an interesting topic. Before starting the actual implementation, We should know the prerequisites to start the actual development.
Prerequisites
Below are the prerequisites for Implementing Azure Face API Using Visual Studio 2019.
- You must have an Azure Valid Subscription or a valid Azure Account. If you don’t have an Azure Account till now, Create an Azure Free account now.
- You must have Visual Studio 2019 installed on your dev machine. If you haven’t had Visual Studio 2019 installed on your machine till now, Install Visual Studio 2019 on your dev machine now.
Creating Microsoft Azure Face API using the Azure Portal
Follow the below steps.
Assuming that you have a Valid Azure Account or Azure Subscription, now let’s start creating the Azure Cognitive Services Face API On Azure Portal.
- Log in to the Azure Portal (https://portal.azure.com/)
- Once you log in to the Azure Portal, Now from the left side menu, click on the + Create a Resource button as highlighted below.

3. Now for the next steps, follow my article to Create the Azure Face API on the Azure Portal.
Assuming that you have created the Azure Cognitive Services Azure Face API on the Azure Portal following the above article. Now my Azure Face API is ready. You can see it below.

4. Once you have created the Azure Face API. The next step is to copy the Key value of the Azure Face API. To copy that, Navigate to the Face API page, click on the Keys and Endpoint from the left navigation and now, you can see Key1 and Key2. You can copy the value of the Key1 and keep it in a notepad.
You can click on the Copy button as highlighted to copy the key value of the Key1. This key value we need to use while creating the WPF application using Visual Studio 2019 to implement the Azure Face API in the next section.

Now our first step is completed, we have our Azure Face API is ready now. We have also copied the Key value of our Azure Face API and kept it in a notepad. Now we will move to the next step, i.e., Creating a WPF application using Visual Studio 2019 and C#.
Creating a WPF application using Visual Studio 2019 and C#
Follow the below steps to create a WPF application.
Open Visual Studio 2019 on your dev machine
Click on the Create a new Project button on the Getting Started window.
Choose the project template as the WPF APP (.NET Framework) and click the Next button.

On the Configure your new project window, provide the below details
- Project Name: Provide a name for your WPF application
- Location: Choose a location where you want to save your WPF application.
- Framework: Select the latest .Net framework. Currently, the latest version of the .Net framework is .Net Framework 4.7.2.
Finally, click on the Create button to create the new project.

Now, you can see the project was created successfully without any issues.

Detection of The Face In An Image Azure Face API And C#
Once the project is created successfully, the next step is, we will have to add two NuGet packages to your Project. To add the NuGet Packages,
Right-click on the Project and then click on the Manage NuGet Packages option, as shown below.

Now click on the Browse tab, search for the Newtonsoft.json NuGet package select the package, and then click on the Install button to install the Newtonsoft.json NuGet package.

In the same way, we need to ad