Your profile

One profile for every MSDEVBUILD site. Only you can see it, and the site owner if you write in.

Lesson 30 of 30

Build an Information Extraction App

Module 2: Microsoft Foundry ⏱ 9 min read Updated

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    All my bookmarks and notes

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    30-second answer

    A lightweight extraction app uses the azure-ai-contentunderstanding Python package. It creates a ContentUnderstandingClient with your Foundry endpoint and a credential, calls begin_analyze with an analyzer ID (such as prebuilt-invoice or your custom analyzer) and the file, waits on the poller, then reads result.contents[0].fields. Each field has a value and a confidence, so the app saves high-confidence values and sends low-confidence ones to human review.

    Simulate it » No Azure account needed

    Exam objective: 2.4.4 Build a lightweight application with information extraction capabilities by using Content Understanding. (Skills measured as of April 15, 2026)

    Simulations

    Feel it before you read it. No account needed, nothing leaves this page.

    Azure portal: Call Content Understanding from Python Call an analyzer from Python and read the fields.
    </> Embed

    Embed this simulation

    Free for trainers, teachers and bloggers. Paste this into your page:

    Loading the portal…

    Install the SDK and point it at the <strong>resource endpoint</strong>.

    👆 Click the glowing item in the portal to continue

    Read the steps as text
    1. Install the SDK and point it at the resource endpoint.
    2. begin_analyze starts a long-running job; poller.result() waits for it. Each field has a value and a confidence.
    3. Run it. Low-confidence fields are flagged for a person.

    🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.

    😟 THE PROBLEM

    Your finance team wants invoices processed without opening the portal.

    😊 THE SOLUTION

    A Python app that analyses each file and routes unsure fields to a person.

    • Clicking through the portal✓ begin_analyze in code
    • Long-running analysis✓ Poll for the result
    • Low-confidence values✓ Send to human review
    🛠️ Solved with: Content Understanding SDK

    Start with a question

    How do I get invoice totals into my own app instead of a portal screen?

    Karthik has tested prebuilt-invoice in the Foundry portal and it reads his company’s invoices well. But the finance team doesn’t want to upload files to a portal. They want a script that picks up each new invoice, pulls out the fields and posts them to their system, and only bothers a person when something looks unsure.

    That’s a small Python app with the azure-ai-contentunderstanding package: about 25 lines that call an analyzer and read the results.

    Explain it like I’m 10

    The technical explanation

    Every Content Understanding app follows the same four steps, whatever the content type.

    1. 1 Connect

      ContentUnderstandingClient with endpoint and credential.

    2. 2 Analyze

      begin_analyze with an analyzer ID and the file.

    3. 3 Wait

      poller.result() returns when the job is done.

    4. 4 Use

      Read fields, check confidence, save or send to review.

    The extraction app loop

    What you need

    • A Foundry resource with Content Understanding available and default model deployments set (analyzers call them).
    • The resource endpoint (it looks like https://<resource-name>.services.ai.azure.com/) and either a key or Microsoft Entra ID access.
    • An analyzer ID: a prebuilt one such as prebuilt-invoice, or a custom analyzer you created in the portal.

    The app

    # extract_app.py
    # pip install azure-ai-contentunderstanding
    import os
    from azure.ai.contentunderstanding import ContentUnderstandingClient
    from azure.ai.contentunderstanding.models import AnalysisInput
    from azure.core.credentials import AzureKeyCredential
    
    client = ContentUnderstandingClient(
        endpoint=os.environ["CONTENTUNDERSTANDING_ENDPOINT"],
        credential=AzureKeyCredential(os.environ["CONTENTUNDERSTANDING_KEY"]),
    )
    
    invoice_url = "https://example.com/invoices/inv-1042.pdf"  # your file's URL
    
    # 1. Start the analysis (it runs asynchronously)
    poller = client.begin_analyze(
        analyzer_id="prebuilt-invoice",
        inputs=[AnalysisInput(url=invoice_url)],
    )
    
    # 2. Wait for it to finish
    result = poller.result()
    fields = result.contents[0].fields
    
    # 3. Read each field and route by confidence
    THRESHOLD = 0.85
    needs_review = []
    for name, field in fields.items():
        confidence = field.confidence or 0
        print(f"{name}: {field.value} (confidence {confidence:.2f})")
        if confidence < THRESHOLD:
            needs_review.append(name)
    
    # 4. Save or send to a person
    if needs_review:
        print("Send to review:", ", ".join(needs_review))
    else:
        print("All fields confident. Post to the finance system.")

    Points worth knowing:

    • begin_ means a long-running operation. You get a poller back straight away and call .result() to wait.
    • result.contents is a list. For one file you read contents[0], which also has the Markdown of the document if you want the full text.
    • Each field has a value and a confidence. Some fields (generated ones, for example) may not carry a confidence, which is why the code treats a missing score as 0.
    • To switch to keyless auth, replace AzureKeyCredential(...) with DefaultAzureCredential() from azure.identity after az login.

    Same code, different content

    Only the analyzer ID and the input change between content types:

    ContentAnalyzer ID
    Invoiceprebuilt-invoice
    Receiptprebuilt-receipt
    Photo descriptionprebuilt-imageSearch
    Call recordingprebuilt-audioSearch
    Videoprebuilt-videoSearch
    Your own fieldsYour custom analyzer’s ID
    Architect level Making the review step useful

    A review queue only helps if the reviewer can act fast. Store the grounding with each low-confidence field so your review screen can highlight the spot on the page or the timestamp in the recording. Set thresholds per field rather than one global number: a wrong invoice total costs more than a wrong supplier phone number. Track how often reviewers correct each field; if they almost never change a value, you can lower its threshold and send fewer documents to people.

    Real-world business scenario

    Logistics

    Contoso Logistics, Mumbai

    The problem
    Delivery receipts and supplier invoices arrived by email all day, and two people spent most of their week copying values into the accounts system.
    What they used
    A small Python job watches the inbox folder, runs prebuilt-invoice or prebuilt-receipt through ContentUnderstandingClient, posts fields above a 0.85 confidence threshold straight to the accounts system and sends the rest to a review page.
    Why that choice
    The SDK call is the same for every analyzer, so one script covers both document types, and confidence scores decide what needs a person.
    The result
    The two staff members now spend about an hour a day on flagged values instead of typing every document.

    When to use it and when not to

    ✓ Use it when…

    • Batch or event-driven jobs that pull fields from documents, images, audio or video into your own systems.
    • Workflows that need automatic routing of low-confidence values to people.
    • Reusing one script across content types by switching the analyzer ID.

    ✕ Think twice when…

    • A one-off look at a single file. Testing in the Foundry portal is quicker.
    • Real-time voice or chat experiences. Content Understanding analyzes files asynchronously.
    • Posting high-value transactions without any human review of uncertain fields.

    ↔ Alternatives to consider

    • **The Foundry portal** to test analyzers before writing code.
    • **The REST API** directly if you're not using Python.
    Ready for more?The full lesson adds the technical explanation, when to use it, interview questions and revision notes.

    Test yourself with exercises

    5 original practice questions in the AI-901 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.

    Question 1

    Question 1 of 5

    You are writing a Python application that extracts fields from receipts by using Azure Content Understanding. Which client class should you create?

    Question 2

    Question 2 of 5

    Your code calls client.begin_analyze(analyzer_id="prebuilt-invoice", inputs=[...]). What must the code do next to obtain the extracted fields?

    Question 3

    Question 3 of 5 · Select 2

    Which TWO properties of an extracted field should an application read to save a value and decide whether it requires human review?

    Question 4

    Question 4 of 5

    An application currently extracts invoice fields by calling begin_analyze with the prebuilt-invoice analyzer. The company now wants the same application to summarize recorded support calls.

    What is the minimum change required?

    Question 5

    Question 5 of 5

    A developer wants the ContentUnderstandingClient to authenticate without storing a resource key in code or configuration. What should the developer use?

    Interview preparation

    Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.

    Beginner What are the main steps in a Python app that uses Content Understanding?

    Model answer

    Install azure-ai-contentunderstanding, create a ContentUnderstandingClient with the endpoint and a credential, call begin_analyze with the analyzer ID and the file, call result() on the poller, then read the fields from result.contents[0].fields.

    Interviewer follows up

    Why does the method start with begin?

    You

    Because analysis is a long-running operation. begin_analyze returns a poller straight away, and result() waits until the job finishes.

    Intermediate How do you authenticate the ContentUnderstandingClient?

    Model answer

    Either with an AzureKeyCredential using the resource key, or with DefaultAzureCredential so it uses Microsoft Entra ID. For anything beyond a quick test I prefer Entra ID, so there's no key to leak.

    Experienced developer How would you design the review step?

    Model answer

    I loop over the fields, compare each confidence to a threshold set per field, and if any important field is below it I put the whole document in a review queue with the low fields highlighted. I tune thresholds on a test set and log how often reviewers change values, so I can raise or lower them later.

    Scenario Your extraction app works on invoices, and now the business wants it to handle call recordings too. What changes?

    Model answer

    Very little code. I'd switch the analyzer ID to prebuilt-audioSearch or a custom analyzer based on prebuilt-audio and point the input at the recording. The client, begin_analyze, the poller and the field-reading loop stay the same.

    Quick revision

    Key points

    • Install azure-ai-contentunderstanding and create a ContentUnderstandingClient with the endpoint and a credential.
    • begin_analyze takes an analyzer ID and inputs, and returns a poller.
    • poller.result() returns the result; fields live in result.contents[0].fields.
    • Each field has a value and a confidence between 0 and 1.
    • Route values below your confidence threshold to a person.

    Important terminology

    azure-ai-contentunderstanding
    The Python package for calling Azure Content Understanding analyzers.
    ContentUnderstandingClient
    The SDK client you create with the Foundry endpoint and a credential to run analyzers.
    begin_analyze
    The method that starts an analysis job and returns a poller, because analysis runs asynchronously.
    Poller
    An object that waits for a long-running job; poller.result() returns the analysis result when it's done.
    Confidence threshold
    The score you choose below which a value goes to a person instead of straight into your system.

    Common mistakes

    • Forgetting to call result() on the poller and trying to read fields from the poller itself.
    • Hard-coding the key in the script. Use environment variables or DefaultAzureCredential.

    Exam tips

    • "Start analysis from Python" = begin_analyze on ContentUnderstandingClient.
    • "Decide which values need a person" = compare each field's confidence to a threshold.

    Five quick revision questions

    1. 1.Which Python package calls Content Understanding?Show

      azure-ai-contentunderstanding.

    2. 2.Which client class do you create?Show

      ContentUnderstandingClient.

    3. 3.Which method starts an analysis?Show

      begin_analyze.

    4. 4.Where are the fields in the result?Show

      result.contents[0].fields.

    5. 5.Which two properties do you read from a field?Show

      value and confidence.

    Official references

    Finished this lesson? Tick it off. Your progress is saved in this browser.

    Studying with a friend? Send them this lesson

    It's free and needs no sign-up. Their progress saves in their own browser.

    Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges. Play ❯

    Install MSDEVBUILD Azure

    Free · no account · works offline

    Save the whole course for offline ›

    Hi, I’m your Nimbus

    Your study buddy. Pick what we do next.

    MSDEVBUILD · Multi-Stack Dev Build

    Sign in to MSDEVBUILD

    One account for Azure certifications and the blog: sign in here and you are signed in on both. Your XP, streak, practice deck and certificate stay in sync on every device. Optional: everything works without an account.