Leverage Cognitive Services with Azure Functions
    • Dark
      Light
    • PDF

    Leverage Cognitive Services with Azure Functions

    • Dark
      Light
    • PDF

    Article Summary

    #ServerlessTips - Azure Functions
    Author: Steef-Jan Wiggers Azure MVP

    The Microsoft Azure Platform offers over 25 Cognitive Services ranging from text analysis to face detection. These services allow you to build Artificial Intelligence powered solutions. Furthermore, you as a developer do require any machine learning skills as you will leverage the services doing all the heavy lifting.

    To leverage the services, all you need to do is call one of the APIs exposed by the Cognitive Services. First, you provision one of the cognitive services depending on your requirement. For instance, when analyzing faces on a picture, you can provision the Computer Vision service. Subsequently, when you have provisioned the service, you will get an endpoint you can call. The URL of the endpoint will have the following format:

    https://.api.cognitive.microsoft.com

    And you will add depending on the API the name of the service, method, and request parameters – for computer vision this could be:

    vision/v2.0/analyze?visualFeatures=Adult

    Note that the operations of the computer vision API are available in an API document, and you can download the definition in swagger and wadl format.

    Furthermore, to be able to call the API, you need an access key, which you will provide the header of your request. Therefore, when you want to use the Computer Vision API in your function, you use HttpClient and build the request message as shown below:

    Cognitive Services with Azure Functions

    In the code, you see an instance of HttpClient with a request header containing the access to call the vision endpoint (i.e. https://westeurope.api.cognitive.microsoft.com/analyze?visualFeatues=Adult). Furthermore, the request includes the payload, i.e. the image (content) as a stream.

    Azure-functions.png

    With Azure Functions, you can leverage Cognitive Services and build serverless AI-powered solutions.

    Was this article helpful?