If your pipeline runs on Azure Document Intelligence, the first thing it does with a result is not read it. It waits. The analyze call returns an Operation-Location header, your code polls that URL until status reads succeeded or failed, and only then does it open analyzeResult. After that, a mapper takes over: Microsoft's field names on one side, your column names on the other, and a switch statement in between that picks the right value property for each type.
That mapper is the subject of an Azure Document Intelligence migration. Unlike a pipeline built on raw OCR, yours already receives fields. They are Microsoft's fields, though, named by a prebuilt model or by a custom model you trained, and your system of record has its own. This piece maps one onto the other, and points at the three places where a migration breaks quietly.
Some teams are migrating whether they planned to or not. Microsoft's version table lists v4.0 (2024-11-30) as the current GA release, v2.1 as retiring on September 15, 2027, and v3.0 as retiring on March 30, 2029. Moving from v2.1 already means rewriting the code that read readResults, pageResults, and documentResults, because v3.0 redesigned the API, so it is a natural moment to ask which contract the rewrite should target.
What an analyzeResult is
Microsoft's documentation groups the response into content, layout, style, and semantic elements. The parts a migration has to account for are these:
- Content — one top-level
contentstring with all the text in reading order. Every other element points into it throughspans, each anoffsetand alength. - Layout —
pageswith words, lines, and selection marks;paragraphs;tableswith cells by row and column index; and, from the layout model,figuresandsections. - Key-value pairs —
keyValuePairs, from the general document and invoice models, where the key is text that has to appear on the page. - Documents —
documents, each with adocTypesuch asprebuilt:invoiceand afieldsdictionary. This is what prebuilt and custom models return, and what most production code reads.
Each field in that dictionary carries a type, a typed value property (valueString, valueDate, valueNumber, valueCurrency, valueArray, valueObject, and others), the content it was read from, boundingRegions with a page number and a polygon, spans, and a confidence. Line items arrive as an array field such as Items, whose elements are objects with their own subfields.
Azure field to schema field, row by row
The table below maps each construct to what your code does with it today and to what a field in a schema you declare carries instead. Field names on the right are illustrative.
| Azure construct | What your code does today | What the schema field carries |
|---|---|---|
modelId and documents[].docType | Picks a mapper per model, and per custom model version | A document type you name, with one schema per type. |
fields keys such as VendorName, InvoiceId, AmountDue | Renames Microsoft's canonical names to your columns through a lookup table | Fields named after your system of record, such as supplier_name or invoice_number. The rename table goes away. |
type with valueString, valueDate, valueNumber | Switches on type to choose which value property to read | One value, already in the type and format the schema declares. |
valueCurrency with amount and currencySymbol | Turns a symbol into a currency code, or guesses one | An amount and a currency as separate typed fields, each with its own evidence. |
valueArray of valueObject, such as Items | Flattens subfields into line-item rows | An array of objects with the properties your ledger expects. |
content next to the normalized value | Stores the value, shows the content in review screens | The value plus a citation to the page it was read from. |
tables from layout, and keyValuePairs | Maps header text or key text to fields where no document field exists | The same named field. Our extraction API page describes the output: typed fields with confidence scores and page citations. |
confidence per field, a decimal such as 0.973 in Microsoft's sample | Compares against a threshold to flag review | A confidence per field. The example on our extraction API page shows 0.99: the scale looks the same, the calibration is not. |
boundingRegions and spans | Draws highlights from polygons, slices content by offset | A citation per field: the page and the region the value came from. |
Three places a migration breaks quietly
None of these throws an error. Each produces a plausible value that is wrong, which is worse.
- Offsets have a unit — spans count user-perceived characters by default. The
stringIndexTypeparameter switches them to Unicode code points or UTF-16 code units, and Microsoft's own sample response sets it totextElements. Code that slicescontentwith offsets counted in another unit drifts on the first accented name or emoji. If old records store spans, store the unit with them. - Types vary by model and example — the concept page shows
InvoiceTotalas acurrencywithvalueCurrency, while the v4.0 REST sample returnsAmountDueas anumberwithvalueNumber. Microsoft also notes that custom models may return dates outside ISO 8601. Readtypeon every field; never infer it from the field name. - Coordinates have a page unit — polygons are expressed in the unit of the page, generally pixels for images and inches for PDFs, as four points clockwise from the top left. Highlights that look right on scans can land in the wrong place on digital PDFs, and the reverse. Check them on both before a reviewer relies on them.
There is a fourth, smaller one. Microsoft distinguishes extracted fields, which carry content, from inferred fields, which carry only a value. A review screen that shows content as the evidence for every field shows nothing for the inferred ones. Decide what evidence an inferred value gets before you compare outputs.
What migrates is the mapper, not the model
List every place in your code that reads analyzeResult. In most pipelines the list falls into five groups:
- Polling and retries — the loop around
Operation-Location. Its replacement depends on how the new API is called, and its failure handling has to be rewritten, not deleted. - Rename tables — the maps from Microsoft field names to yours, one per model. With a schema in your own names they are deleted.
- Type switches and normalizers — the code that picks a value property and fixes currencies, dates, and addresses. Some of it moves into the schema's types. Keep the business rules that are yours, such as which amount counts as the total due.
- Review thresholds — the numbers that decide what a person sees. Both services publish confidence as a decimal, which makes it tempting to keep them. Set them again from your own review data instead.
- Evidence and audit — highlights, spans, and stored polygons. Records that cite Azure spans or regions keep meaning only if you keep the original result with them. Decide whether history stays as it was or is re-extracted before the first document takes the new path.
Custom models need one more line in the inventory. Each one encodes labeling work: the fields someone chose and the sample documents they tagged. That list of fields is the first draft of your schema, and the tagged samples are your test set. Neither should be thrown away with the model.
Run both on the same documents
Compare the value your system stores after your mapper has run against the value the schema returns. Comparing raw text, or comparing Azure's field names to anything, measures the wrong thing.
- Use your own documents — the ones that already reach review, plus the samples you labeled for custom models.
- Run in shadow — keep Azure on the live path, write the new output to a side table, and diff field by field.
- Record review effort — for each document, which fields each path would have sent to a person, and why.
- Read every disagreement — some are errors on the new side; others are rename-table entries that were wrong all along.
Our document extraction benchmark guide describes the method. We cite no accuracy figures here: the only ones worth having come from your documents.
When staying on Azure is the better call
Not every pipeline should leave. If your documents match the prebuilt models, if you need Azure's certifications for federal workloads, or if your platform team is standardizing on Microsoft Foundry and Azure Content Understanding, moving from v2.1 or v3.0 to v4.0 may be all the migration you need. A hybrid is reasonable too: keep Azure for layout and OCR, and add a schema-based extraction step where your own field names and review routing matter. Our Azure Document Intelligence comparison sets out where each fits.
If you are migrating more than one service, the shape of the work differs. Textract returns blocks that your code assembles into fields; Azure returns fields that your code renames. Our piece on the AWS Textract migration covers the other case.
Before you switch the live path
- An inventory of result readers — every function that reads
analyzeResult, sorted into the five groups above. - A schema per document type — written from your system of record, using custom model field lists as a draft.
- The units written down — string index type for spans, page unit for polygons, and the type of every field you store.
- Thresholds set from shadow data — per field, not carried over because the range matches.
- A rollback — the Azure path stays deployable until the shadow diff is quiet for long enough to trust.
