---
title: "Azure Document Intelligence flips valueDate on a composed front+back ID image"
url: "https://www.dariuszparys.com/notes/azure-document-intelligence-flips-valuedate-on-composed-id-image"
author: "Dariusz Parys"
published: 2026-11-12T00:00:00.000Z
description: "Document Intelligence returned a month-first valueDate for a German ID card when front and back were sent as one image, so a fix to the date parser changed nothing."
---

# Azure Document Intelligence flips valueDate on a composed front+back ID image

## Context

An identity check reads a German ID card through Azure Document Intelligence (`prebuilt-idDocument`). It kept offering the birth date as `08.12.1983` for a card printed `12.08.1983`. That happened even after a fix that made the mapper parse the printed text day first. The tests for that fix passed, and the swap stayed.

## Insight

A date-parsing fix can pass every test and change nothing. The provider swaps day and month inside its normalised `valueDate`, before your parser ever runs.

- **Front only:** classified as `idDocument.nationalIdentityCard`, and `valueDate` is correct.
- **Front and back stacked into one image:** classified as `idDocument.passport`. The machine-readable zone is lost, and `valueDate` comes back month first.

| Field       | `content`    | `valueDate`  |
| ----------- | ------------ | ------------ |
| DateOfBirth | `12.08.1983` | `1983-12-08` |

The mapper read `valueDate` first and fell back to `content` only when it was missing, so the day-first fix was never reached. Running the captured response through the pre-fix mapper proved it.

## Fix

Prefer `content` when it matches a dotted day-first format (`dd.MM.yyyy`, `d.M.yyyy`); otherwise keep `valueDate`. Don't treat slashes as day first, because they're ambiguous on US documents. They stay with the provider's reading.

```csharp
string[] printedDayFirst = ["dd.MM.yyyy", "d.M.yyyy"];
if (DateOnly.TryParseExact(content?.Trim(), printedDayFirst,
        CultureInfo.InvariantCulture, DateTimeStyles.None, out date))
{
    return true; // printed text wins
}
// else: valueDate, then the other fallbacks
```

## Investigation traps

- Capture what the reader actually sends, which is the composed image bytes, not the file the user picked.
- Write test fixtures in the shape the .NET SDK serialises, not the REST shape:

```csharp
// SDK shape: what the mapper sees
BinaryData.FromObjectAsJson(analyzeResult);
// -> "ValueDate":"1983-12-08T00:00:00+00:00", "Content":"12.08.1983"

// REST shape (not what the mapper sees)
// -> "valueDate":"1983-12-08", "content":"12.08.1983"
```
