Reconcile Azure OpenAI Batch Expiry Without Losing Results
Azure OpenAI Batch exposes job timestamps, file identifiers, request counts, and an expired state, while input and output artifacts follow separate retention settings. This guide reconciles the provider object with a local manifest, downloads every available result once, distinguishes missing work from failed work, and preserves evidence before files disappear.

Azure OpenAI Batch has several clocks. The batch object carries processing timestamps and can report expired. Input files can receive an explicit expiry. Generated output and error files have their own retention behavior, and the job record can outlive those artifacts. Reconciliation must read the provider's returned state and download every available artifact. It must also account for each expected request before a cleanup timer removes the evidence.
TL;DR
- Keep batch processing state and input-file expiry separate from output-file expiry and local retention.
- Reconcile the returned status, timestamps, request counts, output file ID, and error file ID against an immutable row manifest.
- Download and fingerprint every available artifact before cleanup, then classify each expected request once.
- Never infer completion or expiry from a local 24-hour timer when the provider object is available.
Four clocks govern one batch
Microsoft's Azure OpenAI Batch guide requires a 24h completion window in the creation request and exposes status plus timestamps on the Batch object. The same documentation also describes explicit input and output expiration settings between 14 and 30 days, says generated output and error files have no default expiration, and retains terminal batch job records for up to 365 days.
Treat those facts as four records:
- The processing clock belongs to the Batch object and its provider-returned status.
- The input-file clock controls the uploaded source artifact.
- The output-file clock controls generated result and error artifacts when explicitly set.
- The enterprise retention clock controls your copied evidence after download.
Each timestamp answers a narrower question. A visible batch record can outlive retrievable files. An existing output file proves that an artifact remains available, while row-level accounting establishes which expected requests received results.
My blunt view is that a calendar reminder called delete batch after 30 days fails the retention test. Each clock needs an owner and a recorded action.
Provider state outranks a local timer
The Batch object includes status, created_at, in_progress_at, expires_at, finalizing_at, completed_at, failed_at, expired_at, cancellation timestamps, request counts, and result file identifiers. Persist the full object on each meaningful transition while extracting those fields into typed columns.
Use the returned status as the provider fact. A worker-calculated deadline should create an operational alert while leaving provider status unchanged. Microsoft's page describes the service aim and the available expired state in different sections. Preserve what the API actually returns. Keep its timestamps and error details with that status.
Polling failures create an unknown local state. Keep retrying under a bounded operations policy and preserve the last provider observation separately. Once the object reports a terminal result, freeze that snapshot and begin artifact reconciliation. The AI agent action lineage guide explains why observed provider state and application decisions need separate entries.
Draw four small clocks on the runbook margin: batch, input, output, archive. If an operator cannot name which clock fired, the automation should not delete anything.
Reconciliation starts with the submission manifest
Before upload, create one immutable manifest row for every JSONL request. Bind custom_id to the source record, canonical request fingerprint, deployment, policy version, submitting identity, and expected downstream action. Store the input file digest and provider file ID at the manifest header.
When a terminal or operationally held state arrives, retrieve both output_file_id and error_file_id when present. Download each artifact to controlled storage and record retrieval identity and time. Calculate a complete-file digest before parsing. Then parse lines independently and join them to manifest rows by custom_id.
Assign one reconciliation state to every expected row. Useful states include succeeded, provider-failed, missing, duplicate, malformed, unauthorized, quarantined, and written. Keep the provider execution outcome separate from the downstream write result. A successful model response can still fail application schema or authorization checks.
The Batch custom ID correlation guide covers occurrence counting and split result files. Expiry reconciliation adds the deadline and custody controls around that join.
Request counts cross-check the ledger
Microsoft's Batch object reports total and completed request counts. It also reports failed request counts. Compare those values with the manifest row count and parsed artifact totals. Any difference creates a reconciliation hold.
Counts alone cannot identify the missing row. Two duplicated result lines can make a total look correct while one expected custom_id never appears. Count unique expected identifiers, unknown identifiers, duplicates, malformed lines, and cross-file collisions before calculating closure.
For an expired or failed job, expect partial evidence to require careful handling. Apply the same handling to a cancelled job. Download any result and error artifacts the object exposes. Preserve the terminal status and timestamps, then classify manifest rows absent from both artifacts as missing under that batch outcome. Never resubmit those rows under the same custom_id; a new batch needs new submission identity linked to the prior attempt.
The AI audit log chain-of-custody guide applies to provider downloads. Keep the original artifact reference and digest beside parsed row fingerprints so later review can reproduce the accounting.
File expiry needs a scheduled retrieval control
Microsoft allows expires_after on an input upload and output_expires_after on batch creation. The documented explicit range is 14 through 30 days, anchored to creation time. Generated output and error files remain until deletion when no explicit output expiration is set. Your application still needs an internal retrieval deadline because credentials and network policy can remove access earlier than a theoretical default. Account state or deliberate cleanup can do the same.
Schedule retrieval as soon as the batch reaches a state that exposes artifacts. Retry idempotently and store a receipt containing file ID, provider byte count when available, local byte count, digest, retrieval time, and authenticated workload identity. Mark artifact_copied only after durable storage confirms the write and a second read verifies the digest.
Microsoft's Azure OpenAI quotas and limits page separates batch input-file limits from output artifacts and directs customers toward explicit input expiration or Blob Storage when managing scale. Capacity cleanup and evidence retention are related operations with different acceptance criteria.
Cleanup follows verified closure
A terminal provider status can start reconciliation. Deletion requires additional evidence: every expected row has an explainable state and both available artifacts have verified copies. Unknown and duplicate lines must be resolved or quarantined, and downstream writes must be idempotently recorded.
Create a cleanup approval containing the batch ID, final object fingerprint, input file ID, result file IDs, manifest version, row-state totals, artifact digests, retention class, and approver. Delete provider files only when enterprise policy calls for deletion and the evidence copy has passed verification. Record the provider deletion response separately.
Microsoft's data privacy documentation explains that Batch processing handles uploaded customer data and distinguishes service processing from customer-controlled application storage. Your copied artifacts become application-held data, so access and encryption must follow the classifications in the original manifest. The deletion policy must follow them too.
The tamper-evident audit logs guide provides the integrity pattern for the final evidence packet.
Acceptance tests need missing and late artifacts
Use a test manifest with successful and failing requests, then force these cases:
- The polling worker misses several intervals and resumes after the provider state changed.
- The batch object exposes only an error file, only an output file, both, or neither.
- One
custom_idappears in both artifacts. - Provider request counts disagree with unique parsed identifiers.
- An output download truncates before the final newline.
- Two retrieval workers race to copy the same artifact.
- Local storage commits the file but crashes before writing the receipt.
- Cleanup starts before one artifact digest has been verified.
- An explicit file-expiry setting passes before the retrieval worker succeeds.
The expected outcome is a named hold or a closed evidence packet, never silent success. Run cleanup fixtures only in an isolated Azure resource with disposable content and approved identities.
DeepInspect
DeepInspect can inspect authenticated HTTP batch creation and status exchanges deliberately routed through its proxy. File exchanges become visible when the client routes them through the same boundary. Route and identity policy can then govern each operation, with the supplied manifest or artifact digest preserved in a per-decision record.
The batch client remains responsible for polling, interpreting Azure's returned state, downloading artifacts, reconciling row manifests, enforcing retention, and deleting files. Recovery of an expired provider artifact sits outside DeepInspect's HTTP enforcement boundary. Direct Azure and Blob Storage traffic also requires routing through the proxy for visibility. Use Azure's object as the provider fact and the local ledger as the reconciliation fact.
Book a technical deep dive at deepinspect.ai.
Frequently asked questions
- Does the 24-hour completion window authorize local expiry?
Submit the documented completion-window value, then read the provider Batch object. Preserve its returned status and timestamps without replacing them with a local deadline state.
- Do output and error files expire automatically?
Microsoft states that generated output and error files have no default expiration. They remain until deletion or an explicit output expiration setting. Download them promptly anyway and verify the copied bytes under your retention policy.
- Can a terminal batch be deleted immediately?
Deletion waits for manifest closure, verified artifact copies, resolved anomalies, retention approval, and a recorded cleanup result.
- What should happen to rows missing after expiry?
Mark them missing under the original batch outcome and preserve the evidence. A retry belongs to a new batch and a new submission identifier linked to the prior manifest row. This keeps both attempts visible.