Invoke Azure Cognitive Services from Power Automate

Introduction

Create Cognitive Service API Subscription

Create the Flow

Test the Implementation

Summary

Introduction

Cognitive Services are a set of machine learning algorithms that Microsoft has developed to solve problems in the field of Artificial Intelligence (AI).In this article, we will be using the Computer Vision API to analyze the text within the image uploaded to SharePoint and we will see how we can save it back to a column in SharePoint Library.

Create Cognitive Service API Subscription

Before we can use it in flow we have to subscribe to it and get the keys so that we can authenticate to the API from the flow. Head over to the Cognitive Service blade in Azure Portal and click on Add.

This will list out all the available cognitive service APIs. Select Computer Vision.

It will open up the dialog box where we can name the instance of the Computer Vision API and select the pricing tier and resource group.

Once it’s created, head over to the Overview section from which we can get the endpoint and keys which will be used within the flow. Take a note of it.

Create the Flow

Now let’s head over to the Flow Portal and create the flow with the trigger “When a file is created” so that the flow will run whenever an image is uploaded to the library.

Add the Get File Content action so as to retrieve the file content of the recently uploaded image. We will be using the File Content output from this action within the cognitive analysis action. Now, add the Computer Vision API action and specify the name and the Account Key as well as the endpoint URL which we had noted down earlier.

On Clicking create it will establish the connection with the API and provide us the option to enter the Image Source and Image Content. Select Image Content as the value for Image Source and Specify File Content (output from Get File Content action) as the value for Image Content

Finally, we will save the output of the Cognitive analysis action which is the description of the image back to the SharePoint Library

Test the Implementation

Let’s test the logic by uploading the image of the Taj Mahal to the library. Ideally, this should kickstart the flow and run the cognitive analysis on the image and save the description of the image back to SharePoint Library

The flow has run successfully and has created a description

Heading over to the library we can see the description saved against the image

Summary

Thus, we saw how we can utilize Computer Vision Cognitive Analysis in union with Power Automate to derive the description of an image uploaded to SharePoint

Related Articles

Author

Author

Priyaranjan KS is a Modern Workplace Architect primarily focused on developing and architecting solutions around Office 365,Power Platform and Azure.He is also a Microsoft Most Valuable Professional(MVP) and a Microsoft Certified Trainer(MCT)

Latest Articles