Text analysis with Azure Language and MCP
Back to the AI-901 path
AI-901Chapter 9

Microsoft AI-901 Certification Study

Text analysis with Azure Language and MCP

NLP, generative models, Azure Language in Foundry Tools, SDK, Responses API, agents, and MCP server

Suggested study time: 50 minutes • Beginner level • Original rewrite based on Microsoft Learn objectives

Neon Microsoft Certified AI-901 Azure AI Fundamentals shield surrounded by AI, language, vision, speech, and agent symbols

1. Text analysis and natural language processing

Natural language processing (NLP) brings together techniques that help computers interpret, understand, and respond to human language. Text analysis turns unstructured content into useful information by identifying sentiment, important words and phrases, entities, topics, and relationships.

The same capability supports very different scenarios. Customer-service teams examine reviews, tickets, and surveys for trends and dissatisfaction; healthcare organizations extract symptoms, medications, and diagnoses from clinical records; financial institutions find rates, parties, and compliance risks in contracts and loans; legal teams summarize cases, locate clauses, and classify documents by topic.

  • Distinguish flexible analysis with generative models from structured Azure Language operations.
  • Connect a client application through the Responses API or the Azure AI Text Analytics library.
  • Extend an agent with Azure Language MCP server for specialized tasks.
Pipeline that transforms unstructured text into insights and actions.
Reviews, documents, and messages pass through NLP to produce structured signals for people, applications, and agents.

2. and two analysis approaches

is the Azure platform for building AI applications and agents. Work starts with a Foundry resource, which provides access to services and models, and a Foundry project, the workspace that organizes deployments, playgrounds, connections, tools, and assets.

Two complementary approaches are available. A general-purpose generative model interprets prompts and combines tasks conversationally; it suits work where flexibility and natural language matter. provides specialized NLP functions with known response schemas and more consistent behavior for automated pipelines.

Comparison of the two text-analysis approaches.
ApproachStrengthTypical use
Generative modelFlexibility, context, and combined instructionsExploration, open questions, summarization, translation, and compound analysis.
Structured, repeatable, automation-ready outputLanguage detection, entities, sentiment, key phrases, and PII redaction.
Comparison of a generative model and Azure Language in Foundry Tools.
Choose according to the balance between conversational flexibility and deterministic output.

3. Flexible analysis with generative models

After deploying a model, the Foundry playground accepts a passage and a natural-language description of the required analysis. The same model can extract key phrases, recognize or link entities, classify sentiment, mine opinions, summarize, translate, answer questions, assign custom categories, or chain several of these tasks in one interaction.

For a restaurant review, a key-phrase request might surface references to the dinner, city, dishes, and service. In another passage, entity recognition can separate a person, location, organization, date, time, duration, percentage, number, and dimension. Entity linking can associate an ambiguous mention with a known identity.

Examples that an entity analysis can structure.
CategoryExample
PersonJohn Smith
LocationNew York
OrganizationMicrosoft
DateMay 2, 2017
Time8:00 AM
Duration3 hours
Percentage25%
Number40
Dimension10 miles

Sentiment is commonly labeled positive, negative, or neutral, while opinion mining can explain what was praised or criticized. A generative response is probabilistic, so prompt wording matters: asking only for overall sentiment tends to produce a short answer, whereas requesting sentence-level evidence, reasons, and an output format produces a more detailed result.

Original Microsoft Foundry playground screenshot showing text analysis with gpt-4.1-mini.
The interface screenshot remains a PNG and demonstrates prompt-driven flexible analysis.

4. Purpose-built Azure Language capabilities

uses language models and statistical techniques designed for specific operations. Rather than freely composing an answer, a tool returns predictable fields and scores, which is valuable when another system must validate, store, or route the result.

In the new Foundry portal, these capabilities appear under Build, Models, and AI services; the classic portal may look different. Features include language detection, sentiment and opinion analysis, key phrase extraction, named entity recognition, entity linking, PII and PHI detection, text analytics for health, custom classification, and summarization.

Original screenshot of the AI services list in Microsoft Foundry.
The AI services area collects specialized tools that can be explored in the portal.
Map of key Azure Language text-analysis capabilities.
Purpose-built operations transform documents into language, sentiment, entities, key phrases, PII, and structured summaries.

5. Language detection and PII identification

Language detection

Language detection examines text and returns the predominant language, potentially including a regional variant, an ISO 639-1 code, and a confidence score. For “¡Hola! Me llamo Josefina y vivo en Madrid, España.”, the demonstrated result is Spanish, code es, and confidence 1.00. An application can use the output to route support, select translation, or choose a localized workflow.

Original Azure Language language-detection screenshot.
The result identifies Spanish, the es code, and 100% confidence.

Personally identifiable and health information

PII detection locates data that identifies a person, such as a name, phone number, email address, or street address. The same family of capabilities can recognize PHI in healthcare scenarios. Each occurrence receives a category and confidence value; the service can also produce a redacted copy that masks sensitive spans.

Original Azure Language PII identification and redaction screenshot.
The playground marks a person, phone number, and address and shows a redacted copy.

6. Client applications, APIs, and libraries

A client application gathers text, authenticates to a service, sends a request, and interprets the response. An API is the contract that defines how software exchanges data; a client library is ready-made code that represents that contract with language-specific classes and methods, reducing the need to construct raw HTTP requests.

For models deployed in , the resource endpoint and key enable an Azure OpenAI-compatible API. For specialized operations, the Azure AI Text Analytics library supplies Azure Language clients. Do not embed keys in source code: use environment variables, a secret store, or managed identity in production.

Client application selecting the Responses API or Azure Language SDK.
The client sends text to the appropriate endpoint and receives either flexible text or structured data.

7. Responses API with the OpenAI library

The Responses API is a modern unified interface for interactions with Azure OpenAI-compatible models. It works well for conversational and open-ended analysis, but does not by itself guarantee an identical rigid schema on every run. The OpenAI Python library wraps the communication so code does not have to assemble headers and JSON manually.

# Install
pip install openai python-dotenv

# .env
AZURE_OPENAI_ENDPOINT=https://<your-resource>.openai.azure.com/openai/v1/
MODEL_DEPLOYMENT_NAME=gpt-4.1-mini
API_KEY=<your-foundry-key>
import os
from dotenv import load_dotenv
from openai import OpenAI

load_dotenv()
foundry_client = OpenAI(
    base_url=os.environ['AZURE_OPENAI_ENDPOINT'],
    api_key=os.environ['API_KEY']
)

analysis = foundry_client.responses.create(
    model=os.environ['MODEL_DEPLOYMENT_NAME'],
    input='Classify the sentiment and explain the main reasons in this review: ...'
)
print(analysis.output_text)

OpenAI is the class supplied by the library; foundry_client is an authenticated instance of that class. responses.create sends input to the named deployment. The deployment name can be chosen during deployment and may match the model name. Run the file from the terminal with python followed by the script name.

8. Azure Language SDK for structured results

When a workflow requires consistent categories and scores, the Azure Language SDK is the direct choice. The azure-ai-textanalytics package creates a TextAnalyticsClient from the resource endpoint and an AzureKeyCredential. Operations accept a list of documents even when the application analyzes only one passage.

# Install
pip install azure-ai-textanalytics python-dotenv

# .env
AZURE_LANGUAGE_ENDPOINT=https://<your-resource>.cognitiveservices.azure.com/
API_KEY=<your-key>
import os
from dotenv import load_dotenv
from azure.core.credentials import AzureKeyCredential
from azure.ai.textanalytics import TextAnalyticsClient

load_dotenv()
language_client = TextAnalyticsClient(
    endpoint=os.environ['AZURE_LANGUAGE_ENDPOINT'],
    credential=AzureKeyCredential(os.environ['API_KEY'])
)

sample = 'Maria Garcia can be reached at maria@example.com.'
language = language_client.detect_language([sample])[0]
pii = language_client.recognize_pii_entities([sample])[0]

print(language.primary_language.name, language.primary_language.iso6391_name,
      language.primary_language.confidence_score)
print(pii.redacted_text)
for entity in pii.entities:
    print(entity.text, entity.category, entity.confidence_score)

detect_language provides the language name, ISO code, and confidence. recognize_pii_entities supplies redacted text plus entities with text, category, and confidence. This predictability simplifies rules, auditing, and storage; generative models remain useful when the task needs explanation or freely combined operations.

9. Agents, tools, and Model Context Protocol

An agent combines a model with instructions and tools to reason, plan, retrieve information, and call external services. Although a generative model can interpret text, free-form output is not always suitable for processes that require deterministic data. Adding Azure Language as a tool combines general reasoning with specialized analysis.

Model Context Protocol (MCP) is an open standard that acts as a common adapter between agents and tools. The MCP client—usually the agent or host application—discovers capabilities and sends calls. The MCP server publishes tools and data, receives parameters, runs the operation, and returns a structured result. This separation keeps agent logic clean and makes tools replaceable and extensible.

Azure Language MCP server is a managed bridge for language detection, sentiment, key phrases, entities, PII, and other capabilities. Agent code does not need to implement every REST call or manage service tokens directly. A server can also expose a compound action, such as processing a batch of documents.

MCP client-server architecture connecting an agent to Azure Language.
The agent discovers and invokes tools; the server validates the call, runs Azure Language, and returns structured data.

10. Connect Azure Language to an agent

In the portal, deploy a model or choose an existing deployment and save the configuration as an agent. Add a tool, search for , and select its MCP server. The connection uses the Foundry resource name; because the resource already includes these tools in the demonstrated scenario, no separate Azure Language resource is required.

Original screenshot of agent creation in Microsoft Foundry.
The playground configuration is saved under a reusable name.
Original screenshot of the Azure Language MCP server connection.
The tool is added from the catalog and connected to the Foundry resource.

Instructions should state when the tool is appropriate and what format is expected. The agent can detect a ticket language before routing it to the right team or redact PII before the rest of the workflow reads the message. The model selects the route; the tool performs the specialized analysis.

Original screenshot of an agent using an Azure Language tool.
The result shows the tool invocation and its response integrated into the agent conversation.

11. Exercise: explore text analysis

The guided exercise compares a generative-model NLP workload and an operation in the same environment. Allow about 20 minutes and use an Azure subscription; new accounts may include credits for the first 30 days.

  1. Open or create a project and select a model deployment.
  2. Test a text-analysis prompt and observe how instruction changes affect the response.
  3. Open AI services, run language detection or another structured operation, and inspect its code, confidence, and fields.
  4. Compare flexibility, repeatability, and format before choosing an application integration.
Original language-detection result from the exercise.
In the exercise, the tool identifies French with 100% confidence.

12. Knowledge check

Reworded questions

  1. Which option provides statistical, structured, deterministic analysis: a generic prompt, the Azure Language SDK, or only the playground?
  2. What role does the client object created by a library play inside an application?
  3. How does a Foundry agent access Azure Language capabilities through a standardized interface?

Explained answers

  • The Azure Language SDK calls purpose-built operations and returns predictable fields and scores.
  • The client stores endpoint and credential configuration and communicates between application code and the service.
  • Azure Language MCP server publishes the capabilities as tools that the agent can discover and invoke.

13. Chapter summary and official references

  • NLP helps computers interpret human language; text analysis extracts structure and meaning from unstructured content.
  • offers flexible generative models and for predictable operations.
  • The Responses API and OpenAI library support conversational analysis; the Azure AI Text Analytics SDK supports structured workflows.
  • An agent combines model reasoning with tools; Azure Language MCP server standardizes access to specialized functions.
  • Customer service, healthcare, finance, and legal teams can use these techniques to locate signals, entities, risks, and topics at scale.