Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Serverless computing in Azure with .NET

You're reading from   Serverless computing in Azure with .NET Build, test, and automate deployment

Arrow left icon
Product type Paperback
Published in Aug 2017
Publisher Packt
ISBN-13 9781787288393
Length 468 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Sasha Rosenbaum Sasha Rosenbaum
Author Profile Icon Sasha Rosenbaum
Sasha Rosenbaum
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Preface 1. Understanding Serverless Architecture FREE CHAPTER 2. Getting Started with the Azure Environment 3. Setting Up the Development Environment 4. Configuring Endpoints, Triggers, Bindings, and Scheduling 5. Integrations and Dependencies 6. Integrating Azure Functions with Cognitive Services API 7. Debugging Your Azure Functions 8. Testing Your Azure Functions 9. Configuring Continuous Delivery 10. Securing Your Application 11. Monitoring Your Application 12. Designing for High Availability, Disaster Recovery, and Scale 13. Designing Cost-Effective Services 14. C# Script-Based Functions 15. Azure Compute On-Demand Options

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...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image