tokens&
For enterprises
Submit
Sign in
tokens&

Build better AI stacks, claim useful opportunities, and give AI infrastructure companies a source-labeled adoption readout they can trust.

For buildersFor enterprises

Product

  • For builders
  • Category rankings
  • Startup credits and perks
  • Agent Skills
  • Platform
  • Submit project, tool, product, or perk

Enterprise

  • Start free company workspace

Community

  • Community
  • Newsletter
  • Events
Xin

© 2026 tokensand, LLC. All rights reserved.

  • Terms
  • Privacy
  • Security
  • Data Processing
  • Status
Agent Skills/Azure text analytics for Python
MicrosoftModelsSKILL.mdVerified source

Agent Skill

Azure text analytics for Python

Add sentiment, entity, key phrase, language, PII, and healthcare text analysis to Python apps.

Install this skillView repository

Vendor-authored source · MIT license.

Raw SKILL.mdInstall the Tokens& Agent Pack

Skill specification

Declared by Microsoft in the package front matter. Trigger conditions are what the coding agent matches on before it loads the skill.

View package fields
Azure text analytics for Python SKILL.md front matter fields
Skill nameazure-ai-textanalytics-py
Trigger conditionsAzure AI Text Analytics SDK for sentiment analysis, entity recognition, key phrases, language detection, PII, and healthcare NLP. Use for natural language processing on text. Triggers: "text analytics", "sentiment analysis", "entity recognition", "key phrase", "PII detection", "TextAnalyticsClient".
Declared licenseMIT
Version1.0.0
AuthorMicrosoft
Packageazure-ai-textanalytics

Install azure-ai-textanalytics-py

In a terminal with Node.js, npm and Git, run the command for your agent. The Skills CLI installs the complete package directory, including referenced files within it. Review its install prompt, then start a new agent session. A skill package does not set up an MCP server connection.

Claude Code

.claude/skills/azure-ai-textanalytics-py/SKILL.md

Project skills are committed with the repo. Use the user directory for a personal install across every project.

Project install

npx skills add 'https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-python/skills/azure-ai-textanalytics-py' --skill 'azure-ai-textanalytics-py' --agent 'claude-code'
Install for all projects instead

Personal install

npx skills add 'https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-python/skills/azure-ai-textanalytics-py' --skill 'azure-ai-textanalytics-py' --agent 'claude-code' --global

Codex

.agents/skills/azure-ai-textanalytics-py/SKILL.md

Codex reads `.agents/skills/` as its primary location, which is also the cross-platform default other clients honour.

Project install

npx skills add 'https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-python/skills/azure-ai-textanalytics-py' --skill 'azure-ai-textanalytics-py' --agent 'codex'
Install for all projects instead

Personal install

npx skills add 'https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-python/skills/azure-ai-textanalytics-py' --skill 'azure-ai-textanalytics-py' --agent 'codex' --global

Cursor

.agents/skills/azure-ai-textanalytics-py/SKILL.md

Cursor also loads `.agents/skills/`, `.claude/skills/`, and `.codex/skills/`, so one committed copy can serve several clients.

Project install

npx skills add 'https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-python/skills/azure-ai-textanalytics-py' --skill 'azure-ai-textanalytics-py' --agent 'cursor'
Install for all projects instead

Personal install

npx skills add 'https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-python/skills/azure-ai-textanalytics-py' --skill 'azure-ai-textanalytics-py' --agent 'cursor' --global

Gemini CLI

.agents/skills/azure-ai-textanalytics-py/SKILL.md

Gemini CLI reads `.agents/skills/` first when both directories exist.

Project install

npx skills add 'https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-python/skills/azure-ai-textanalytics-py' --skill 'azure-ai-textanalytics-py' --agent 'gemini-cli'
Install for all projects instead

Personal install

npx skills add 'https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-python/skills/azure-ai-textanalytics-py' --skill 'azure-ai-textanalytics-py' --agent 'gemini-cli' --global

GitHub Copilot

.agents/skills/azure-ai-textanalytics-py/SKILL.md

The Skills CLI uses the shared `.agents/skills/` directory for Copilot project installs.

Project install

npx skills add 'https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-python/skills/azure-ai-textanalytics-py' --skill 'azure-ai-textanalytics-py' --agent 'github-copilot'
Install for all projects instead

Personal install

npx skills add 'https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-python/skills/azure-ai-textanalytics-py' --skill 'azure-ai-textanalytics-py' --agent 'github-copilot' --global

SKILL.md

View raw source

Published by Microsoft under MIT. Rendered from the package in github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-python/skills/azure-ai-textanalytics-py.

Read full skill instructions

Azure AI Text Analytics SDK for Python

Client library for Azure AI Language service NLP capabilities including sentiment, entities, key phrases, and more.

Installation

pip install azure-ai-textanalytics

Environment Variables

AZURE_LANGUAGE_ENDPOINT=https://<resource>.cognitiveservices.azure.com  # Required for all auth methods
AZURE_TOKEN_CREDENTIALS=prod # Required only if DefaultAzureCredential is used in production
AZURE_LANGUAGE_KEY=<your-api-key>  # Only required for the legacy API-key auth path below

Authentication & Lifecycle

🔑 Two rules apply to every code sample below: 1. Prefer `DefaultAzureCredential`. It works locally (Azure CLI / VS Code / Developer CLI) and in Azure (managed identity, workload identity) with no code change. Avoid connection strings, account/API keys — they bypass Entra audit and rotation. - Local dev: DefaultAzureCredential works as-is. - Production: set AZURE_TOKEN_CREDENTIALS=prod (or AZURE_TOKEN_CREDENTIALS=<specific_credential>) to constrain the credential chain to production-safe credentials. 2. Wrap every client in a context manager so HTTP transports, sockets, and token caches are released deterministically: - Sync: with <Client>(...) as client: - Async: async with <Client>(...) as client: and async with DefaultAzureCredential() as credential: (from azure.identity.aio) Snippets may abbreviate this setup, but production code should always follow both rules.
import os
from azure.identity import DefaultAzureCredential, ManagedIdentityCredential
from azure.ai.textanalytics import TextAnalyticsClient

# Local dev: DefaultAzureCredential. Production: set AZURE_TOKEN_CREDENTIALS=prod or AZURE_TOKEN_CREDENTIALS=<specific_credential>
credential = DefaultAzureCredential(require_envvar=True)
# Or use a specific credential directly in production:
# See https://learn.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#credential-classes
# credential = ManagedIdentityCredential()

with TextAnalyticsClient(
    endpoint=os.environ["AZURE_LANGUAGE_ENDPOINT"],
    credential=credential,
) as client:
    languages = client.detect_language(["Hello, world!"])

Legacy: API Key (existing keyed deployments)

New code should use DefaultAzureCredential above. Use AzureKeyCredential only if you have an existing keyed deployment that hasn't been migrated to Entra ID yet — for example, regulated environments still completing their Entra rollout.

import os
from azure.core.credentials import AzureKeyCredential
from azure.ai.textanalytics import TextAnalyticsClient

with TextAnalyticsClient(
    endpoint=os.environ["AZURE_LANGUAGE_ENDPOINT"],
    credential=AzureKeyCredential(os.environ["AZURE_LANGUAGE_KEY"]),
) as client:
    languages = client.detect_language(["Hello, world!"])

Sentiment Analysis

documents = [
    "I had a wonderful trip to Seattle last week!",
    "The food was terrible and the service was slow."
]

result = client.analyze_sentiment(documents, show_opinion_mining=True)

for doc in result:
    if not doc.is_error:
        print(f"Sentiment: {doc.sentiment}")
        print(f"Scores: pos={doc.confidence_scores.positive:.2f}, "
              f"neg={doc.confidence_scores.negative:.2f}, "
              f"neu={doc.confidence_scores.neutral:.2f}")
        
        # Opinion mining (aspect-based sentiment)
        for sentence in doc.sentences:
            for opinion in sentence.mined_opinions:
                target = opinion.target
                print(f"  Target: '{target.text}' - {target.sentiment}")
                for assessment in opinion.assessments:
                    print(f"    Assessment: '{assessment.text}' - {assessment.sentiment}")

Entity Recognition

documents = ["Microsoft was founded by Bill Gates and Paul Allen in Albuquerque."]

result = client.recognize_entities(documents)

for doc in result:
    if not doc.is_error:
        for entity in doc.entities:
            print(f"Entity: {entity.text}")
            print(f"  Category: {entity.category}")
            print(f"  Subcategory: {entity.subcategory}")
            print(f"  Confidence: {entity.confidence_score:.2f}")

PII Detection

documents = ["My SSN is 123-45-6789 and my email is john@example.com"]

result = client.recognize_pii_entities(documents)

for doc in result:
    if not doc.is_error:
        print(f"Redacted: {doc.redacted_text}")
        for entity in doc.entities:
            print(f"PII: {entity.text} ({entity.category})")

Key Phrase Extraction

documents = ["Azure AI provides powerful machine learning capabilities for developers."]

result = client.extract_key_phrases(documents)

for doc in result:
    if not doc.is_error:
        print(f"Key phrases: {doc.key_phrases}")

Language Detection

documents = ["Ce document est en francais.", "This is written in English."]

result = client.detect_language(documents)

for doc in result:
    if not doc.is_error:
        print(f"Language: {doc.primary_language.name} ({doc.primary_language.iso6391_name})")
        print(f"Confidence: {doc.primary_language.confidence_score:.2f}")

Healthcare Text Analytics

documents = ["Patient has diabetes and was prescribed metformin 500mg twice daily."]

poller = client.begin_analyze_healthcare_entities(documents)
result = poller.result()

for doc in result:
    if not doc.is_error:
        for entity in doc.entities:
            print(f"Entity: {entity.text}")
            print(f"  Category: {entity.category}")
            print(f"  Normalized: {entity.normalized_text}")
            
            # Entity links (UMLS, etc.)
            for link in entity.data_sources:
                print(f"  Link: {link.name} - {link.entity_id}")

Multiple Analysis (Batch)

from azure.ai.textanalytics import (
    RecognizeEntitiesAction,
    ExtractKeyPhrasesAction,
    AnalyzeSentimentAction
)

documents = ["Microsoft announced new Azure AI features at Build conference."]

poller = client.begin_analyze_actions(
    documents,
    actions=[
        RecognizeEntitiesAction(),
        ExtractKeyPhrasesAction(),
        AnalyzeSentimentAction()
    ]
)

results = poller.result()
for doc_results in results:
    for result in doc_results:
        if result.kind == "EntityRecognition":
            print(f"Entities: {[e.text for e in result.entities]}")
        elif result.kind == "KeyPhraseExtraction":
            print(f"Key phrases: {result.key_phrases}")
        elif result.kind == "SentimentAnalysis":
            print(f"Sentiment: {result.sentiment}")

Async Client

from azure.ai.textanalytics.aio import TextAnalyticsClient
from azure.identity.aio import DefaultAzureCredential

async def analyze():
    async with DefaultAzureCredential() as credential:
        async with TextAnalyticsClient(
            endpoint=endpoint,
            credential=credential
        ) as client:
            result = await client.analyze_sentiment(documents)
            # Process results...

Client Types

ClientPurpose
TextAnalyticsClientAll text analytics operations
TextAnalyticsClient (aio)Async version

Available Operations

MethodDescription
analyze_sentimentSentiment analysis with opinion mining
recognize_entitiesNamed entity recognition
recognize_pii_entitiesPII detection and redaction
recognize_linked_entitiesEntity linking to Wikipedia
extract_key_phrasesKey phrase extraction
detect_languageLanguage detection
begin_analyze_healthcare_entitiesHealthcare NLP (long-running)
begin_analyze_actionsMultiple analyses in batch

Best Practices

  1. Pick sync OR async and stay consistent. Do not mix azure.ai.textanalytics sync clients with azure.ai.textanalytics.aio async clients in the same call path. Choose one mode per module.
  2. Always use context managers for clients and async credentials. Wrap every client in with TextAnalyticsClient(...) as client: (sync) or async with TextAnalyticsClient(...) as client: (async). For async DefaultAzureCredential from azure.identity.aio, also use async with credential: so tokens and transports are cleaned up.
  3. Use batch operations for multiple documents (up to 10 per request)
  4. Enable opinion mining for detailed aspect-based sentiment
  5. Use async client for high-throughput scenarios
  6. Handle document errors — results list may contain errors for some docs
  7. Specify language when known to improve accuracy

Reference Files

FileContents
references/capabilities.mdAdditional non-hero capabilities, operation-group coverage, and production checklists.
references/non-hero-scenarios.mdDedicated non-hero examples for secondary/advanced scenarios.

More Microsoft Agent Skills

All Agent Skills

Application Insights web instrumentation

Instrument browser apps for RUM, dependencies, exceptions, custom events, and correlated agent traces.

Frontend

Azure AI content safety for Python

Detect harmful text and image content with severity-aware moderation workflows in Python.

Models

Azure AI Projects for TypeScript

Build Foundry applications with project clients, agents, deployments, datasets, indexes, and evaluations.

Agents

Azure AI Search for TypeScript

Build vector, hybrid, semantic, and agentic retrieval workflows with the Azure AI Search SDK.

Backend

Azure cloud solution architect

Design and review Azure systems against architecture patterns and Well-Architected Framework tradeoffs.

Backend

Azure Cosmos DB for TypeScript

Implement Cosmos DB document CRUD, queries, partitioning, bulk operations, and container management.

Backend