Lesson 5 of 5 Information Extraction with Content Understanding

Building an Information Extraction Application

This lesson explains how a lightweight extraction application submits content to an analyzer, waits for the asynchronous result and processes the fields, using the Python client library or the REST pattern.

Learning outcomes

After completing this lesson, you will be able to:

  • Identify the one-time setup that Content Understanding requires.
  • Analyze content with the Python SDK.
  • Describe the asynchronous REST pattern.
  • Read fields and confidence values from a result.

One-time setup

Content Understanding runs on a Foundry resource. Before the first analysis, the resource needs deployments of a supported chat completion model (such as a GPT-5 series model) and an embedding model (text-embedding-3-large), registered as the resource's default deployments. Content Understanding Studio can configure the defaults, and deploy the models automatically, when you connect a resource; in code, a PATCH request to the defaults endpoint maps model names and aliases to deployment names.

Analyzing with the Python SDK

The client library is azure-ai-contentunderstanding. A ContentUnderstandingClient takes the resource endpoint, https://<resource>.services.ai.azure.com/, and a credential such as DefaultAzureCredential. begin_analyze() takes the analyzer ID and a list of inputs and returns a poller, because analysis is a long-running operation; poller.result() waits until it completes.

import os
from azure.identity import DefaultAzureCredential
from azure.ai.contentunderstanding import ContentUnderstandingClient

client = ContentUnderstandingClient(endpoint=os.environ["FOUNDRY_ENDPOINT"], credential=DefaultAzureCredential())
poller = client.begin_analyze(analyzer_id="prebuilt-invoice",
                              inputs=[{"url": "https://example.com/invoices/inv-1042.pdf"}])
result = poller.result()                 # waits for the asynchronous analysis
for content in result.contents:
    print(content.markdown[:500])
    print(content.fields)

The REST pattern

With the REST API, the application sends POST /contentunderstanding/analyzers/{analyzerId}:analyze with the inputs. The response is 202 Accepted with an Operation-Location header. The application polls that URL until the status is Succeeded (or Failed) and then reads the result. Custom analyzers are created with PUT /contentunderstanding/analyzers/{analyzerId} and a definition that contains the base analyzer and field schema.

The following diagram shows the requests an application makes.

The asynchronous REST pattern for analysis. The application sends POST to the analyzer's analyze operation with the inputs. The service replies 202 Accepted with an Operation-Location header, and the body has no fields yet. The application polls that URL until the status is Succeeded or Failed, and only then reads the result.
Reading the first response too early finds no fields.
Put in order

Analyze with REST

Exam skills 2.4.4

Put the steps of a Content Understanding REST analysis in order.

Log in to try this activity Interactive activities are free with an account.

Reading results

The result's contents list has one entry per analyzed item (or per segment for video). Each entry has markdown and fields. Each field has a type, a type-specific value such as valueString, valueNumber, valueDate, valueArray or valueObject, a confidence score and source information. The application stores high-confidence values and routes low-confidence ones to a review queue.

Match the pairs

Typed field values

Exam skills 2.4.4

Match each value property with an invoice field that uses it.

Log in to try this activity Interactive activities are free with an account.
Worked example

A script that returns too early

A developer calls the analyze REST operation for a 40-page PDF and immediately reads the response body, which contains no fields.

Analysis is asynchronous: the first response only acknowledges the request. The script must read the Operation-Location header and poll it until the status is Succeeded, or use the SDK's begin_analyze() and call result() on the poller, which handles the polling.

Check yourself

What must be configured on the Foundry resource before Content Understanding can analyze content?

Show answer

Default chat and embedding model deployments, which Content Understanding uses.

Exam Tips

Remember for the exam

  • Configure default chat and embedding model deployments on the resource first.
  • begin_analyze() returns a poller; result() waits for completion.
  • REST: POST :analyze, then poll Operation-Location until Succeeded.
  • Fields carry type-specific values and confidence scores.