• Sep 11, 2025

Detecting Sentiment in Customer Reviews Using Azure AI Language resource and .NET Core

Customer feedback is a goldmine of insight — but only if you can interpret it at scale. In this article, we’ll walk through how to build a simple yet powerful sentiment analysis API using Azure AI Language Service and .NET Core, capable of classifying reviews as positive, neutral, or negative.

Customer feedback is a goldmine of insight — but only if you can interpret it at scale. In this article, we’ll walk through how to build a simple yet powerful sentiment analysis API using Azure AI Language Service and .NET Core, capable of classifying reviews as positive, neutral, or negative.

Step 1: Azure Setup — Provisioning the Language Service

What to Do in Azure Portal:

  1. Create a new resource:
     Go to Azure Portal → Create Resource → Search for “Azure AI Language”

  1. Configure the resource:

  • Region: Choose a supported region (e.g., East US)

  • Pricing Tier: Standard S (for production workloads)

  • Resource Group: Create or reuse one

Once the resource is created get the endpoint and keys as shown below:

Step 2: Building the .NET Core Wrapper API

Let’s break down the code that wraps Azure’s sentiment analysis into a clean RESTful endpoint.

Dependencies
Install the Azure SDK:

dotnet add package Azure.AI.TextAnalytics

ReviewRequest Model

public class ReviewRequest
{
    public string Text { get; set; }
}

This model captures the review text sent by the client.

LanguageController

 [Route("api/[controller]")]
 [ApiController]
 public class LanguageController : ControllerBase
 {

     [HttpPost("analyzeReview")]
     public async Task<IActionResult> AnalyzeReview([FromBody] ReviewRequest request)
     {
         if (string.IsNullOrWhiteSpace(request.Text))
             return BadRequest("Review text is required.");

         var response = await AnalyzeSentimentAsync(request.Text);

         //return Ok(response);
         return Ok(response.Value.Sentiment.ToString());
         //I’m extremely disappointed with this product.It stopped working within a week, and the customer support was completely unhelpful. I expected better quality for the price I paid.Definitely not recommending this to anyone.
     }

     private async Task<Response<DocumentSentiment>> AnalyzeSentimentAsync(string text)
     {
         var endpoint = new Uri(AzureAIConstants.LanguageEndpoint);
         var credential = new AzureKeyCredential(AzureAIConstants.LanguageApiKey);

         TextAnalyticsClient _client = _client = new TextAnalyticsClient(endpoint, credential);

         var response = await _client.AnalyzeSentimentAsync(text);
         return response; // Positive, Negative, Neutral
     }

 }

What’s Happening Here:
• The controller exposes a endpoint.
• It receives a review string, validates it, and passes it to Azure’s .
• Azure returns a sentiment classification: , , or .
• The result is returned as plain text in the response.

Step 3: Testing the API with Swagger or Postman

Swagger (if enabled)
• Run your project (dot net)
• Navigate to (http://localhost:<port>/swagger/)
• Find (/api/Language/analyzeReview)
• Enter a sample review:

{
  "text": "I’m extremely disappointed with this product. It stopped working within a week, and the customer support was completely unhelpful."
}