Text Analysis & Translation
Prompted analysis vs Azure Language · NER · sentiment · PII · structured outputs · harm categories · Azure Translator (NMT and LLM) · customizing outputs
By the tools4free.dev team · Last reviewed November 13, 2026
Practice questions for this topic →
Two ways to analyze text in Foundry
The Foundry portal offers two approaches: general-purpose AI models driven by natural language prompts, and purpose-built language tools that return structured, deterministic results for specific tasks.
| Question | General-purpose model (Responses API) | Azure Language in Foundry Tools |
|---|---|---|
| How is the task defined? | A natural language prompt: sentiment, entities, summaries, translation, questions and more, with no configuration or training | A purpose-built analyzer per task, such as language detection or PII detection |
| Output consistency | Can vary between calls because the model generates text probabilistically | Structured, deterministic output from statistical techniques; suited to automated pipelines |
| Python client | OpenAI client with client.responses.create(...); endpoint ends in /openai/v1/ | TextAnalyticsClient from azure-ai-textanalytics with AzureKeyCredential |
| Pick it when | You need flexible, conversational analysis without a fixed output | You need a consistent language code, confidence score or redacted text |
The SDK methods named in the module: detect_language() takes a list of strings and returns the detected language, its ISO 639-1 code and a confidence score between 0 and 1; recognize_pii_entities() returns the redacted text plus the entities found, each with a category and confidence score.
For agents, Azure Language is also exposed as the Azure Language MCP server (remote in the Foundry Tool Catalog, or local). MCP is an open standard for connecting agents to external tools and data. A Foundry resource already includes access to Language tools, so you don't create a separate Azure Language resource for it.
Azure Language features
| Task | Feature | Group | Customizable? |
|---|---|---|---|
| Detect and redact sensitive information such as PII and PHI | PII detection | Core | No |
| Detect the language of a text | Language detection | Core | No |
| Extract categories of information without a custom model | Prebuilt NER | Core | No |
| Extract categories of information with a model specific to your data | Custom NER | Core | Yes |
| Extract medical information from clinical documents without a model | Text analytics for health | Core | No |
| Extract main topics and important phrases | Key phrase extraction | Legacy | No |
| Sentiment and opinions in text | Sentiment analysis and opinion mining | Legacy | No |
| Summarize long text or conversations | Summarization | Legacy | No |
| Disambiguate entities and link to Wikipedia | Entity linking | Legacy | No |
| Classify documents into your own classes | Custom text classification | Legacy | Yes |
Core capabilities are recommended for new development. Legacy capabilities are supported for existing implementations. Sentiment analysis and opinion mining and Summarization both retire from Azure Language on March 31, 2029; the page says to migrate existing workloads and direct all new projects to Microsoft Foundry.
Summarization
- Extractive: selects key sentences from the document and keeps their original positions. It also returns a rank score per sentence.
- Abstractive: writes new, concise sentences that aren't copied from the source.
- Text summarization accepts only plain text blocks; conversation summarization accepts conversational input; native document summarization accepts Word, PDF or plain text.
- Conversation features: recap, issue/resolution (call center), chapter titles and narrative summarization.
- Job output is available for 24 hours, then purged.
Sentiment, PII and safety detection
Sentiment and opinions
- Labels are negative, neutral and positive, chosen by the highest confidence score.
- Sentiment is evaluated at sentence and document level, with confidence scores from 0 to 1 for each label.
- Opinion mining (aspect-based sentiment) ties opinions to words such as product attributes.
- With a prompted model the output depends on how you phrase the request: you can ask for an overall label or a sentence-by-sentence breakdown.
PII detection feature types
| Feature type | Input | Processing |
|---|---|---|
| Text PII | Raw text strings: apps, prompts, logs, tickets | Synchronous detection and redaction |
| Conversation PII | Turn-based chat or transcript data | Asynchronous, job-based; transcript-aware |
| Document-based PII | Native files (.pdf, .docx, .txt) | Asynchronous, storage-based; keeps document structure and returns JSON metadata |
PII detection runs as-is: there is no customization of the model used on your data. The anonymization (synthetic replacement) feature is in preview.
Harm categories and guardrails
- Content Safety classifies harmful content into four categories: hate, sexual, violence and self-harm, for text and images.
- Severity levels are safe, low, medium and high. Blocking level Low blocks high severity only (least restrictive); High blocks low, medium and high (most restrictive). Safe content is annotated but never blocked.
- Classifiers can give false positives and false negatives: test with representative content in every language you use.
- A guardrail is a named collection of controls. Intervention points: user input, tool call (preview), tool response (preview) and output.
- Outside Foundry, or across several platforms, use Azure AI Content Safety Studio and APIs for a consistent guardrail experience. The Analyze text API scans for sexual content, violence, hate and self harm with multiple severity levels; Prompt Shields scans for user input attacks.
Structured JSON outputs
Structured outputs make a model follow a JSON Schema you supply in the call. The older JSON mode guaranteed valid JSON but couldn't ensure the schema was followed.
| API | Where the schema goes | Python helper |
|---|---|---|
| Chat Completions | response_format | client.beta.chat.completions.parse(..., response_format=Model); result in message.parsed |
| Responses | text.format | responses.parse(..., text_format=Model); result in output_parsed |
- Define the schema with a Pydantic
BaseModelin Python. - Set
strict: trueon a function definition to enable structured outputs for function calling. - Mark every field as required; emulate an optional field with a union type with
null. - Set
additionalPropertiestofalsein every object. - Limits: up to 100 object properties in total and up to five levels of nesting; the root object can't be
anyOf. - Output follows the key order of your schema.
- Not supported with parallel function calls (set
parallel_tool_callstofalse), bring-your-own-data scenarios, Assistants, Foundry Agent Service, orgpt-audioandgpt-audio-mini.
Translation with Azure Translator
Azure Translator in Foundry Tools is a cloud-based neural machine translation service. The latest generally available text translation version is 2026-06-06; it has breaking changes compared with v3.0, so validate before you migrate.
| NMT | LLM | |
|---|---|---|
| Choice in 2026-06-06 | Standard neural machine translation | An LLM deployment (for example GPT-5.1); requires a Microsoft Foundry resource |
| Billing | Source-text characters | Processed input and output tokens |
| Array limit per Translate call | 1,000 elements of up to 50,000 | 50 elements of up to 5,000 |
| Extra controls | - | Tone (formal, informal, neutral) and gender-specific output; up to five reference translations or an adaptive dataset index ID |
- Request array is
inputs; response array isvalue. - Operations: Languages (needs no authentication), Translate (one
POSTto one or more target languages) and Transliterate (converts between writing systems). - Authentication: resource key in
Ocp-Apim-Subscription-Key, a time-limited bearer token, or Microsoft Entra ID (managed identities or service principals) for keyless access. - Errors: 401 missing or invalid key; 403 unsupported operation or configuration; 429 rate or quota exceeded; 400 invalid payload or unsupported language.
| Need | Feature |
|---|---|
| Translate batch and complex files, keeping format; needs Blob storage | Document translation (asynchronous) |
| Translate one file, no Blob storage needed | Document translation (synchronous) |
| Adapt supported LLMs with 5 to 10,000 prealigned segment pairs (each up to 500 characters) | Adaptive custom translation |
| Build custom models for domain terminology and style | Custom Translator |
| Dynamic dictionary and preventing translation of chosen text | Text translation v3 features |
Customizing model output for domain tasks
- A system message is a set of high-priority instructions and context that steers how a chat model responds: role, tone, formatting and domain-specific conventions.
- Components: role and task, audience and tone, scope and boundaries, safety guidelines, and tools and data.
- Treat a system message as a testable artifact: build a test set with benign and adversarial prompts and iterate.
- Few-shot examples (example user and assistant turns) condition the model for the current call only; the model isn't permanently changed. No examples is zero-shot.
- In the Chat Completion API, instructions take the form of the system message.
- Cues are often a prefix the model builds on, which directs the output toward the form you want.
- For labels specific to your data, train Custom NER or Custom text classification; prebuilt features can't be changed.
Compliance summarization and domain extraction are not described on a dedicated Learn page. Build them from the pieces above: a system message that fixes role, scope and tone, a JSON Schema for the fields, and few-shot examples; use Custom NER when you need a trained model for your own entity categories.
CLI and PowerShell
| Task | Azure CLI | PowerShell |
|---|---|---|
| Install the Azure Language Python SDK | pip install azure-ai-textanalytics | - |
| Create the Language client | client = TextAnalyticsClient(endpoint=endpoint, credential=AzureKeyCredential(key)) | - |
| Detect the language of a text | result = client.detect_language([text])[0] | - |
| Redact PII in a text | result = client.recognize_pii_entities([text])[0] | - |
| Prompt a deployed model (Responses API) | message = client.responses.create(
model=deployment_name,
input="",
) | - |
| Structured output with Chat Completions | completion = client.beta.chat.completions.parse(
model="MODEL_DEPLOYMENT_NAME", # replace with the model deployment name of your gpt-4o 2024-08-06 deployment
messages=[
{"role": "system", "content": "Extract the event information."},
{"role": "user", "content": "Alice and Bob are going to a science fair on Friday."},
],
response_format=CalendarEvent,
) | - |
| Structured output with Responses | response = openai.responses.parse(
model="gpt-5-mini",
input="Extract the event information from: Alice and Bob are going to a science fair on Friday.",
text_format=CalendarEvent,
) | - |
Exam Tips
Tick each tip once you can answer it without looking.
“Same prompt must give a consistent language code and confidence score in a pipeline” → Azure Language SDK (detect_language), not a prompted model. Trap: Prompted models generate text probabilistically, so wording and format can vary between calls.
“Analyze sentiment, extract entities and summarize with no training or configuration” → Deploy a general-purpose model and prompt it (Responses API). Trap: Custom NER and custom text classification need training on your data.
“Python package for Azure Language text analysis” → azure-ai-textanalytics, client TextAnalyticsClient. Trap: openai is the package for the Responses API, and azure-cognitiveservices-speech is for speech.
“Agent needs deterministic language detection or PII redaction as a tool” → Add the Azure Language MCP server to the agent. Trap: A separate Language resource isn't needed: a Foundry resource already includes Language tools.
“Extract entity categories without building a model” → Prebuilt NER. Trap: Custom NER is the one that trains a model on your own data and categories.
“Extract entity categories specific to your domain's data” → Custom NER (customizable). Trap: Prebuilt NER and PII detection are preconfigured; their models can't be changed.
“Redact PII from chat or call transcripts with turn context” → Conversation PII (asynchronous, job-based). Trap: Text PII is synchronous and for raw strings; Document-based PII is for native files.
“Redact PII in .pdf and .docx files and keep document structure” → Document-based PII (asynchronous). Trap: Text PII takes string payloads, not native files.
“Summary made of sentences copied from the source, with rank scores” → Extractive summarization. Trap: Abstractive summarization writes new sentences that aren't copied.
“Plan for Language sentiment or summarization in a new project” → Both retire March 31, 2029: direct all new projects to Microsoft Foundry. Trap: They are legacy capabilities, supported for existing implementations only.
“Four harm categories in Content Safety guardrails” → Hate, sexual, violence, self-harm. Trap: Prompt attacks and protected material are separate risks, not core harm categories.
“Blocking level that blocks only high-severity content” → Low (least restrictive). Trap: High blocks low, medium and high; safe content is never blocked at any level.
“Model output must match a JSON Schema, Chat Completions call” → response_format with a schema (strict: true). Trap: JSON mode only guarantees valid JSON, not adherence to your schema.
“Same, but with the Responses API” → Schema under text.format; Python responses.parse(text_format=Model), read output_parsed. Trap: response_format is the Chat Completions parameter.
“Structured outputs schema rules” → All fields required (emulate optional with a null union), additionalProperties: false, up to 100 properties and five nesting levels. Trap: The root object can't be anyOf.
“Translate with tone control and reference translations” → Translator 2026-06-06 with an LLM deployment (needs a Foundry resource). Trap: NMT is billed per source-text character, and tone variants are listed for LLM-based translation; v3.0 has a different request and response schema.
“Translate batches of files and keep layout; storage needed” → Asynchronous document translation (Azure Blob storage). Trap: Synchronous document translation handles a single file with no Blob storage.
“Steer tone, role and scope of a chat model for a domain task” → System message with role, audience and tone, and scope; test and iterate. Trap: Few-shot examples only condition the current call; they don't change the model permanently.
Sources
- Understand text analysis in Foundry
- Create a client application that analyzes text
- Use Azure Language with an agent
- What is Azure Language in Foundry Tools
- PII detection in Azure Language
- Sentiment analysis and opinion mining
- Summarization
- Structured outputs
- Harm categories in Azure AI Content Safety
- Guardrails and controls overview
- What is Azure AI Content Safety
- What is Azure Translator in Foundry Tools
- Azure text translation in Microsoft Foundry
- System messages
- Prompt engineering techniques
Checked against Microsoft Learn on November 13, 2026.