Working with document intelligence often starts with a simple requirement: take a file, understand its contents, extract useful information, and make the result available to an application.

That sounds straightforward until the input contains different document types, tables, images, handwritten content, or semi-structured information.

Microsoft Azure Content Understanding provides capabilities for analyzing content across documents and other media. For developers, however, testing analyzers through a graphical interface is not always the most convenient approach. When an analyzer is part of a development or automation workflow, being able to invoke it directly from the command line can make testing much easier.

The Azure Content Understanding CLI provides a developer-friendly way to work with Content Understanding resources and test document analysis from a terminal.

This article walks through a practical command-line workflow, explains where the CLI fits into an application architecture, and shows how developers can use it to validate analyzers before integrating them into an application.

What Is Azure Content Understanding?

Azure Content Understanding is designed to extract structured information from content such as documents, images, audio, and video.

For document workloads, the general workflow looks like this:

Document
   |
   v
Content Understanding Analyzer
   |
   v
Content Extraction
   |
   +---- Text
   +---- Tables
   +---- Fields
   +---- Layout
   +---- Structured Output

Instead of writing a separate parser for every document format, developers can use an analyzer to process the input and return structured information.

Typical scenarios include:

The CLI becomes useful when you want to test these operations quickly without writing application code for every experiment.

Why Use a CLI for Document Analyzer Testing?

A graphical interface is useful for exploring a service, but command-line tools provide several advantages for developers.

Faster Iteration

You can run an analyzer repeatedly against different files without rebuilding an application.

document-a.pdf
document-b.pdf
document-c.pdf

This is useful when tuning an analyzer or validating a document set.

Easy Automation

CLI commands can be incorporated into scripts and CI/CD pipelines.

Build
  |
  v
Deploy Analyzer Configuration
  |
  v
Run Test Documents
  |
  v
Validate Results

Easier Reproduction

A command can be copied into a ticket, script, or troubleshooting document.

Instead of saying:

Upload the document, select the analyzer, choose these settings...

you can provide a reproducible command.

Better Developer Workflow

Developers already use terminals for Azure CLI, Git, package managers, and deployment tools. Adding Content Understanding operations to the same workflow reduces context switching.

Installing the Required CLI Tooling

Before using the Content Understanding CLI, make sure the required Azure tooling and authentication are available on the development machine.

A typical environment includes:

Operating System
       |
       +---- Azure CLI
       |
       +---- Content Understanding CLI
       |
       +---- Azure subscription
       |
       +---- Content Understanding resource

Verify the Azure CLI installation:

az --version

Then authenticate:

az login

For development environments that use multiple Azure subscriptions, check the active subscription:

az account show

If necessary, select the required subscription:

az account set --subscription "<subscription-name-or-id>"

Authentication should use the least-privileged identity required for the operation.

Understanding the Analyzer Workflow

An analyzer defines how Content Understanding should interpret incoming content.

At a high level:

Input
  |
  v
Analyzer
  |
  +---- Content Extraction
  |
  +---- Field Extraction
  |
  +---- Classification
  |
  v
Structured Result

For example, an invoice analyzer might identify:

Invoice Number
Vendor Name
Invoice Date
Subtotal
Tax
Total
Line Items

The exact schema depends on the analyzer configuration and the document-processing scenario.

The CLI allows developers to exercise this workflow without first implementing a complete SDK-based application.

Running an Analyzer from the Command Line

The exact CLI command depends on the installed version and the Content Understanding CLI command surface.

A typical workflow conceptually looks like:

az <content-understanding-command> analyzer analyze \
    --resource-group "<resource-group>" \
    --account-name "<resource-name>" \
    --analyzer-id "<analyzer-id>" \
    --input "<document-path>"

The important parameters are:

Parameter

Purpose

Resource group

Identifies the Azure resource group

Resource name

Identifies the Content Understanding resource

Analyzer ID

Selects the analyzer

Input

Specifies the document to analyze

Because CLI syntax can evolve, developers should use the help command provided by their installed CLI version before putting a command into automation.

For example:

az <content-understanding-command> --help

This is particularly important for preview CLI functionality.

Testing a Local Document

Suppose you have an invoice:

samples/
└── invoice-001.pdf

The first useful test is to submit that document to the analyzer.

az <content-understanding-command> analyzer analyze \
    --analyzer-id "invoice-analyzer" \
    --input "./samples/invoice-001.pdf"

The returned result can then be inspected to determine whether the analyzer extracted the expected information.

A simplified result might resemble:

{
  "invoiceNumber": "INV-1001",
  "vendorName": "Contoso",
  "invoiceDate": "2026-09-10",
  "total": 1250.00
}

The actual response schema depends on the analyzer definition.

Save the Result for Comparison

When testing analyzers, saving the output is often more useful than simply displaying it.

For example:

az <content-understanding-command> analyzer analyze \
    --analyzer-id "invoice-analyzer" \
    --input "./samples/invoice-001.pdf" \
    > result.json

Now the output can be compared with another analyzer version.

result-v1.json
result-v2.json

This is particularly useful when modifying field definitions or analyzer configurations.

Testing Multiple Documents

One of the biggest advantages of command-line workflows is repeatability.

A shell script can process a directory of test documents.

For example:

for file in ./samples/*.pdf
do
    echo "Processing $file"

    az <content-understanding-command> analyzer analyze \
        --analyzer-id "invoice-analyzer" \
        --input "$file" \
        > "./results/$(basename "$file").json"
done

The exact CLI command should be replaced with the syntax supported by the installed Content Understanding CLI version.

The important pattern is:

Test Documents
      |
      v
CLI Loop
      |
      v
Analyzer
      |
      v
JSON Results

This turns manual testing into a repeatable test process.

Validate Extracted Fields

Running the analyzer is only half the job.

You also need to validate the result.

Suppose the expected invoice fields are:

{
  "invoiceNumber": "INV-1001",
  "vendorName": "Contoso",
  "total": 1250.00
}

A simple validation script can check whether required fields are present.

import json

with open("result.json", "r", encoding="utf-8") as file:
    result = json.load(file)

required_fields = [
    "invoiceNumber",
    "vendorName",
    "total"
]

missing_fields = [
    field for field in required_fields
    if field not in result
]

if missing_fields:
    print("Missing fields:", missing_fields)
    raise SystemExit(1)

print("Required fields were extracted.")

This changes the CLI from a manual inspection tool into part of an automated validation workflow.

Comparing Analyzer Versions

Analyzer development often involves iteration.

For example:

Version 1
  |
  v
Test documents
  |
  v
Identify extraction problems
  |
  v
Update analyzer
  |
  v
Version 2
  |
  v
Run same test documents

The CLI makes it easier to repeat the same test set.

You can compare:

Analyzer V1
    vs.
Analyzer V2

For example:

Field

V1

V2

Invoice Number

Extracted

Extracted

Vendor

Extracted

Extracted

Invoice Date

Incorrect

Correct

Total

Correct

Correct

Line Items

Partial

Complete

This gives developers an objective way to evaluate changes.

Handling Different Document Types

A production analyzer should not be tested with only one perfect document.

Create a representative test set:

samples/
├── standard-invoice.pdf
├── scanned-invoice.pdf
├── multi-page-invoice.pdf
├── invoice-with-table.pdf
├── low-quality-scan.pdf
└── handwritten-form.pdf

Each document can reveal different weaknesses.

For example:

Testing Edge Cases

Good analyzer testing includes documents that are intentionally difficult.

Examples include:

Missing invoice number
Very long vendor name
Multiple addresses
Different date formats
Multiple tax entries
Empty table rows
Large line-item tables
Poor image quality
Rotated pages

A useful test matrix might look like:

Test Case

Expected Result

Standard document

All required fields extracted

Missing field

Field remains absent or null

Multi-page document

Data collected across pages

Large table

Rows extracted correctly

Poor scan

Extraction quality remains acceptable

Unsupported input

Clear error

This is much more valuable than testing only a single sample file.

Using CLI Testing in CI/CD

Once the analyzer test can be executed from a script, it can potentially become part of CI/CD.

A simplified pipeline looks like:

Developer Change
      |
      v
Pull Request
      |
      v
Build
      |
      v
Run Analyzer Tests
      |
      +---- Pass ----> Deploy
      |
      +---- Fail ----> Stop

For example, a CI job might execute:

./run-analyzer-tests.sh

The script can:

  1. Authenticate using the pipeline identity.

  2. Submit test documents.

  3. Save analyzer results.

  4. Validate required fields.

  5. Return a non-zero exit code when validation fails.

This makes analyzer quality part of the development lifecycle rather than a manual activity.

Avoid Hard-Coding Credentials

Do not place Azure credentials directly inside shell scripts.

Avoid patterns such as:

az login --username "[email protected]" --password "password"

For automated environments, use the identity and secret-management mechanism supported by your CI/CD platform.

The general principle is:

Source Code
    |
    X
Credentials

Pipeline Identity
    |
    v
Azure Resource

Store secrets outside the repository and give the pipeline only the permissions it needs.

Logging and Troubleshooting

When an analyzer test fails, record enough information to reproduce the problem.

Useful diagnostic information includes:

Analyzer ID
Test document name
Execution timestamp
CLI version
Input type
Request status
Error message
Response status

Avoid logging sensitive document contents when they contain personal, financial, or confidential information.

A better failure record is:

Test: invoice-004.pdf
Analyzer: invoice-analyzer
Status: Failed
Reason: Required field "invoiceNumber" not extracted

rather than copying the entire document or response into a shared log.

Common CLI Testing Mistakes

Testing Only One Document

One successful document does not prove that an analyzer works reliably.

Use a representative test corpus.

Validating Only HTTP Success

A successful service response does not necessarily mean that extraction was correct.

Validate the actual fields returned by the analyzer.

Hard-Coding Credentials

Never commit passwords, keys, or tokens into scripts or repositories.

Use managed identities, service principals, or your CI/CD platform's secure authentication mechanism.

Ignoring CLI Version Changes

Preview CLI functionality can change.

Record the CLI version used by automated tests and verify commands after upgrading tooling.

Testing Only Happy Paths

Real documents contain missing fields, unusual layouts, poor scans, and unexpected values.

Include negative and edge cases.

Treating Extracted Data as Automatically Correct

Content extraction is not the same as business validation.

For example, an extracted invoice total should still be validated against the application's business rules.

A Practical Analyzer Test Structure

A small project can organize analyzer tests like this:

content-tests/
├── samples/
│   ├── invoice-001.pdf
│   ├── invoice-002.pdf
│   └── invoice-invalid.pdf
│
├── expected/
│   ├── invoice-001.json
│   └── invoice-002.json
│
├── results/
│
├── scripts/
│   └── run-tests.sh
│
└── README.md

The workflow becomes:

Samples
   |
   v
Analyzer
   |
   v
Results
   |
   v
Expected vs Actual
   |
   v
Pass / Fail

This structure works well when multiple developers need to reproduce analyzer tests.

When to Use the CLI Versus an SDK

The CLI and an SDK solve different problems.

Scenario

CLI

SDK

Quick manual test

Excellent

More work

Local experimentation

Excellent

Good

Shell automation

Excellent

Possible

CI validation

Excellent

Excellent

Application integration

Limited

Better

Custom business logic

Limited

Better

Production service

Usually not ideal

Better

A useful development process is:

Explore with CLI
      |
      v
Validate Analyzer
      |
      v
Automate Tests
      |
      v
Integrate with SDK/API

The CLI helps answer, "Does the analyzer behave as expected?"

The SDK or API is then used to answer, "How do I integrate that analyzer into my application?"

Conclusion

The Azure Content Understanding CLI provides a practical command-line workflow for developers who need to test and validate document analyzers.

Instead of manually uploading documents and inspecting results one at a time, developers can build repeatable workflows around test documents, analyzer execution, result validation, and automated regression testing.

The biggest advantage is not simply being able to run an analyzer from a terminal. It is the ability to make document analysis repeatable and testable.

A mature workflow can start with a local CLI command, grow into a scripted test suite, and eventually become part of CI/CD.

That progression makes it easier to detect extraction regressions, compare analyzer changes, test difficult documents, and build confidence before integrating Content Understanding into a production application.