Build a Text Analysis App
30-second answer
A lightweight text analysis app sends text to Azure Language in Foundry Tools through the azure-ai-textanalytics Python package. With a TextAnalyticsClient (endpoint + key) you call analyze_sentiment, extract_key_phrases, recognize_entities, recognize_pii_entities for redaction, and begin_abstract_summary for summaries. You can also get the same insights by prompting a deployed language model, which is more flexible but less predictable.
Simulate it » No Azure account neededExam objective: 2.2.1 Build a lightweight application that includes text analysis. (Skills measured as of April 15, 2026)
Simulations
Feel it before you read it. No account needed, nothing leaves this page.
Open <strong>Foundry Tools ➜ Azure Language</strong>, pick <strong>Analyze sentiment</strong> and paste a review.
👆 Click the glowing item in the portal to continue
Read the steps as text
- Open Foundry Tools ➜ Azure Language, pick Analyze sentiment and paste a review.
- Sentiment comes per document and per sentence, and opinion mining links each opinion to its target (breakfast ➜ cold).
- Switch capability: key phrases, named entities, PII redaction, language detection and summarization.
- The same calls in Python use the resource endpoint with TextAnalyticsClient.
🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.
🖱️ Drag to rotate · scroll or pinch to zoom
Text analysis
A hotel review goes in. Azure Language returns the sentiment (positive, neutral, negative), key phrases, named entities (people, places, dates), PII and a short summary.
🤔 What happens if…
Read this tour as text
- Five workload lanes. Most AI apps fall into a few workloads: generative and agentic AI, text analysis, speech, computer vision and information extraction. Each lane here takes a different kind of input and turns it into something useful.
- Text analysis. A hotel review goes in. Azure Language returns the sentiment (positive, neutral, negative), key phrases, named entities (people, places, dates), PII and a short summary.
- Speech to text. Speech recognition turns spoken audio into text: live captions, call transcripts, voice commands. It can also translate speech into another language as you talk.
- Text to speech. Speech synthesis turns text into natural speech with a neural voice. SSML lets you control speed, pitch and pauses. Think audiobooks, voice assistants and accessibility readers.
- Computer vision. A photo goes in. Vision models return a caption, tags, objects with boxes, and any printed or handwritten text (OCR). A multimodal chat model can also answer questions about the picture.
- Image generation. Image-generation models work the other way round: a text prompt goes in and a brand-new image comes out. Guardrails block harmful requests, and generated images are marked with content credentials.
- Extract from documents. Azure Content Understanding reads an invoice and returns fields you defined (vendor, date, total) with a confidence score for each, so low-confidence values can go to a person.
- Extract from audio and video. The same service handles media: an audio call becomes a transcript with speakers and a summary; a video is split into segments with key frames, descriptions and chapters.
Turn a hotel review into sentiment, key phrases, entities, masked personal data and a summary: first in the portal, then from Python.
🎓 Education-only simulation. Your lab is saved in this browser, so you can leave and continue later.
😟 THE PROBLEM
Product reviews need a mood score before they reach the dashboard.
😊 THE SOLUTION
A small app that calls Azure Language for each review.
- No mood score✓ analyze_sentiment
- No topics✓ extract_key_phrases
- Private data leaks✓ recognize_pii_entities
Start with a question
What if a thousand reviews landed overnight and your boss wants a summary by 10 a.m.?
A food-delivery app gets reviews like “Biryani was great but the rider called me five times, my number is 98xxxxxx12”. Someone has to work out the mood, spot what people talk about, and keep phone numbers out of the report.
Reading them all isn’t going to happen. A small Python app that sends each review to Azure Language can do it before your tea’s ready.
Explain it like I’m 10
The technical explanation
Azure Language in Foundry Tools gives you ready-made text analysis behind one endpoint. If you have a Foundry resource you already have it. Copy the endpoint and a key from the resource (or use Microsoft Entra ID), and install the SDK.
pip install azure-ai-textanalytics
export LANGUAGE_ENDPOINT="https://<resource-name>.cognitiveservices.azure.com/"
export LANGUAGE_KEY="<key>"
| Feature | Method | What you get back |
|---|---|---|
| Sentiment analysis | analyze_sentiment | positive / neutral / negative / mixed, scores per sentence |
| Key phrase extraction | extract_key_phrases | A list of main talking points |
| Named entity recognition | recognize_entities | Text, category (Person, Location, DateTime…), confidence |
| PII detection | recognize_pii_entities | Personal data found, plus redacted_text |
| Language detection | detect_language | Language name and ISO code |
| Summarization | begin_abstract_summary / begin_extract_summary | New summary sentences, or the key existing sentences |
text_app.py
import os
from azure.core.credentials import AzureKeyCredential
from azure.ai.textanalytics import TextAnalyticsClient
client = TextAnalyticsClient(
endpoint=os.environ["LANGUAGE_ENDPOINT"],
credential=AzureKeyCredential(os.environ["LANGUAGE_KEY"]),
)
reviews = [
"The biryani was excellent but the rider called me five times. "
"Call me on 9876543210 if there's a refund. Ordered in Chennai on Friday."
]
# Every method takes a LIST of documents and returns one result per document
sentiment = client.analyze_sentiment(reviews)[0]
print("Sentiment:", sentiment.sentiment, sentiment.confidence_scores)
phrases = client.extract_key_phrases(reviews)[0]
print("Key phrases:", phrases.key_phrases)
for entity in client.recognize_entities(reviews)[0].entities:
print(f"Entity: {entity.text} ({entity.category}, {entity.confidence_score:.2f})")
pii = client.recognize_pii_entities(reviews)[0]
print("Redacted:", pii.redacted_text) # the phone number comes back as asterisks
# Summaries run as a long-running operation
poller = client.begin_abstract_summary(reviews)
for doc in poller.result():
print("Summary:", doc.summaries[0].text)
For that review you’d expect mixed sentiment (great food, annoying rider), key phrases like “biryani” and “rider”, entities such as Chennai (Location) and Friday (DateTime), and a redacted line with the number masked.
The alternative: ask a deployed model
You can get the same insights by prompting a chat model in Foundry, using the Foundry SDK from the chat app lesson:
response = openai.responses.create(
model="gpt-4.1-mini", # deployment name
instructions="Return JSON with sentiment, key_phrases and entities. Replace phone numbers with ***.",
input=reviews[0],
)
print(response.output_text)
Azure Language
- Fixed, well-defined outputs
- Confidence scores built in
- Same input gives the same output
- Simple per-text pricing, built for volume
Prompting an LLM
- Any analysis you can describe
- Output shape depends on your prompt
- Can vary between runs
- Pay per token, check results with evaluations
Architect level Plan for the 2029 retirements
Microsoft has announced that key phrase extraction, sentiment analysis, summarization, entity linking, conversational language understanding and custom question answering in Azure Language retire on 31 March 2029, with Foundry models as the suggested path. Language detection, PII detection, NER and Text Analytics for health continue. A new project that leans on sentiment or summaries should either plan a move to prompts on a deployed model or start there.
Real-world business scenario
A Bengaluru food-delivery start-up
- The problem
- Thousands of app reviews and chat transcripts a day, with customers often pasting phone numbers and addresses into them. The support lead needed daily themes without staff reading personal data.
- What they used
- A nightly Python job using azure-ai-textanalytics: recognize_pii_entities first, then sentiment and key phrases on the redacted text, with results written to a dashboard.
- Why that choice
- Fixed outputs with confidence scores were easy to chart day over day, and redaction kept personal data out of the reporting store.
- The result
- The team spotted a spike of 'late rider' complaints in one city within a day instead of a week.
When to use it and when not to
✓ Use it when…
- You need the same structured result for thousands of texts, like sentiment per review.
- Personal data must be masked before text is stored or shared.
- You want confidence scores so low-certainty results can go to a person.
✕ Think twice when…
- The question is open-ended, like "what do customers wish we sold?". Prompt a generative model instead.
- You are starting a new long-term project on a feature that retires in 2029 without a plan to move.
↔ Alternatives to consider
- Prompting a deployed model such as gpt-4.1-mini for custom analysis.
- Content Understanding when the text lives inside documents, audio or video.
Test yourself with exercises
5 original practice questions in the AI-901 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.
Interview preparation
Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.
Beginner Which Azure service would you use to find the sentiment of customer reviews?
Model answer
Azure Language in Foundry Tools. I'd call analyze_sentiment from the azure-ai-textanalytics package and get back positive, neutral, negative or mixed, with confidence scores for each sentence.
Interviewer follows up
What does the app need to connect?
You
The resource endpoint and a key (or a Microsoft Entra ID credential). I keep both in environment variables, never in the code.
Intermediate How would you remove phone numbers and emails from support tickets before storing them?
Model answer
Call recognize_pii_entities. Each result has the entities it found and a redacted_text property with the personal data masked by asterisks, so I'd store redacted_text instead of the original.
Experienced developer Would you use Azure Language or an LLM prompt for sentiment analysis?
Model answer
Azure Language when I want the same structured output every time, with labels and confidence scores, at high volume. An LLM prompt when I need something the fixed features don't do, like 'list the complaints about delivery only'. Microsoft has also announced that some Language features, including sentiment and key phrases, retire in March 2029 in favour of Foundry models, so new projects should weigh that.
Scenario Your app returns 'neutral' for a review written in Tamil. What do you check?
Model answer
I'd check that I'm passing the right language code, or run detect_language first, and confirm that the feature supports that language. Sending text with the wrong language hint is a common reason for odd results.
Quick revision
Key points
- pip install azure-ai-textanalytics; create TextAnalyticsClient(endpoint, AzureKeyCredential(key)).
- analyze_sentiment returns a label plus confidence scores per document and sentence.
- extract_key_phrases, recognize_entities and recognize_pii_entities each take a list of documents.
- recognize_pii_entities gives redacted_text with personal data masked.
- Summaries are long-running operations, begin_abstract_summary or begin_extract_summary.
Important terminology
- Azure Language in Foundry Tools
- The Foundry Tools service (formerly Azure AI Language) for sentiment, key phrases, entities, PII, summarization and more.
- TextAnalyticsClient
- The Python client from azure-ai-textanalytics that calls Azure Language text analysis features.
- PII redaction
- Finding personal data such as phone numbers and email addresses and masking it, returned as redacted_text.
- Confidence score
- A number from 0 to 1 that says how sure the service is about a sentiment label or an entity.
- Abstractive summary
- A summary written in new sentences, as opposed to an extractive summary that picks existing sentences.
Common mistakes
- Passing a single string instead of a list of documents to the client methods.
- Confusing entity recognition (people, places, dates) with key phrases (main talking points).
Exam tips
- "Mask phone numbers in transcripts" = PII detection (redacted_text).
- "Main talking points of a review" = key phrase extraction.
- "Positive or negative" = sentiment analysis.
Five quick revision questions
-
1.Which Python package calls Azure Language text analysis?Show
azure-ai-textanalytics
-
2.Which method masks personal data?Show
recognize_pii_entities (use redacted_text).
-
3.What range do confidence scores use?Show
0 to 1.
-
4.Which sentiment label means both positive and negative sentences?Show
Mixed.
-
5.How else can you get these insights besides Azure Language?Show
Prompt a deployed generative model in Foundry.
Official references
Finished this lesson? Tick it off. Your progress is saved in this browser.
Next up: Answer Spoken Prompts with a Multimodal Model
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.