The text sentiment analytics API call implementation
To implement the call to the Text Sentiment Analytics API from the Function App, we will leverage the shared code to avoid code duplication. We will modify the EvaluateText class we have implemented in the previous chapter to call the API and return a meaningful sentiment score rather than using a random double score value.
To implement the procedure, let's first add the following two settings to the local.settings.json
file so that we can access them across all the functions in the Function App:
"textSentimentApiUrl": "https://westus.api.cognitive.microsoft.com/ text/analytics/v2.0/sentiment", "textSentimentApiKey": "<You API key>"
Note
When publishing the application, remember to add the settings to the App Settings
in the portal.
Now, let's modify the EvaluateText
class to make an asynchronous call to the API.
You may need to add a reference to the System.Configuration
assembly. To do so, in the project tree, right-click...