Image Metadata from Computer Vision API to Sharepoint with Power Automate


Topic: To Update Image Metadata from Computer Vision API to Sharepoint with Power Automate Flow





Overview: This Flow will help to update the Metadata for the images we will upload to the SharePoint. The objects or tags will be provided by the Azure Computer Vision API which will analyze key information from the image by inbuilt ML Algorithms. These tags can be updated to a Column against images in any folder in SharePoint and used for sorting and filtering.

Working Prototype:
Platform required:
  • Azure CV API
  • Microsoft Power Automate(MS Flow)
  • Sharepoint
How to get Azure CV API - You need to create an account on Microsoft Azure and will get free credits to use the API service.

1. Login to Microsoft Azure Portal with this link https://portal.azure.com .
2    On to home page, click on create a resource.



 3. Select the Computer Vision within AI + Machine Leaning.




4. Fill the details to create your API service.




5. Click create and it will take some time to deploy the service, on the next page click on Go to resource.




6. On the resource page you can select Keys and Endpoint and keep a note of both.



Power Automate Flow

In this step, we will create a flow using Microsoft Power Automate by integrating the Computer Vision API to analyze the images uploaded to SharePoint.

  • Open this link Link to open Power Automate and sign in with Microsoft account.

  • In Create tab on the right side click on Automated Flow
  • Provide the Name and Choose the trigger “When a file is created in a folder”. Click Create.

  • It will open the flow designer page and here we can add steps to newly created Flow.
  • Specify the Site Address (It will show available addresses if you have the same account for SharePoint and Microsoft) and Folder Id (by default its shared documents).

  • Click on Add Step and search for Analyze Image and select “Analyze Image(Preview)”



  • Step will get added and asks for Name, Key, and Site URL. So, provide the name for your API service, Key, and endpoint URL. Click on Create.





  • Now we will add steps to update he Metadata to SharePoint.
  • Add step “Send an HTTP request to SharePoint” to reach the file to update the MetaData        URI: /_api/web/getFileByServerRelativeUrl('/sites/Image_AnalyticsFilePath')?$select=ListItemAllFields/ID&$expand=ListItemAllFields
  • Click on Add Dynamic Content and find Filepath.
  • Save the flow and run it, after it starts you can upload the image to SharePoint or just upload an image and flow will run by itself.
  • As it completes you can expand the Step 3 and it will look as below, Copy the Body section in JSON format.

  • Add a step “Parse Json” and declare Content as Body and click on Generate from Sample and paste the Body from the previous step.


  • Before adding the next step we need to add one extra Column in SharePoint Directory for Image Tags.

  • Add Step ‘Update file properties’ and declare the fields. In Image Tags field we need to define custom expression:                                                                                              Join(body('Analyze_Image')?['description']?['tags'],',')

  • We can save the Flow and test it by uploading the images to SharePoint.This will trigger the Flow and flow will call CV API to get tags information and SharePoint HTTP request will update the MetaData to SharePoint against the Image Uploaded.






Comments

Post a Comment