How can I get the result of azure document intelligence get_analyze_batch_result

Krishan Patel 0 Reputation points
2026-10-15T08:12:02.7266667+00:00

I am setting up a batch request to azure document intelligence using the async interface like the following and saving the continuation token. Then in a queue I poll the job using the previously saved continuation token and print out all the statuses. However even when the result is present, and therefore the analysis job is completed, the done() still returns False and status() still says InProgress. This means I can never tell when the batch job is complete without manually checking the storage account.

Is there another way around this? Or can this get fixed?

async def main() -> None:
    continuation_token = "<CONTINUATION_TOKEN>"
    _document_intelligence_client = DocumentIntelligenceClient(
        endpoint="https://index-poc-prod-doc-intelligence.cognitiveservices.azure.com/",
        credential=AzureKeyCredential("<PROD DOC INTELLIGENCE CRED>"),
    )
    poller = await _document_intelligence_client.get_analyze_batch_result(continuation_token)
    print(f"Poller done: {poller.done()}")
    print(f"Poller status: {poller.status()}")

    result: AnalyzeBatchResult = await poller.result()
    print(f"Poller succeeded count: {result.succeeded_count}")
    print(f"Poller failed count: {result.failed_count}")
    print(f"Poller skipped count: {result.skipped_count}")


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

"""
Poller done: False
Poller status: InProgress
Poller succeeded count: 5
Poller failed count: 0
Poller skipped count: 0
"""
Azure Document Intelligence in Foundry Tools

1 answer

Sort by: Most helpful
  1. Qiming Bao 0 Reputation points
    2026-11-04T22:08:38.47+00:00

    Hi Krishan,

    This is how the async poller in azure-core behaves, not a service problem. The job is already done; the poller just hasn't asked the service yet.

    Why done() is False and status() is InProgress

    • get_analyze_batch_result(token) rebuilds the poller from the continuation token without making any request. The token stores the initial 202 Accepted response from begin_analyze_batch_documents, so status() returns the status saved at submission time, InProgress.
    • On the async AsyncLROPoller, done() only returns True after wait() / result() has finished. Unlike the sync poller, it never polls in the background.
    • await poller.result() sends the first GET, sees succeeded, and returns straight away. That is why you get the counts even though done() said False a moment earlier.

    Check the status without blocking

    Ask the poller to send a single status request, then decide:

    
    poller = await client.get_analyze_batch_result(continuation_token)
    
    await poller.polling_method().update_status()    # one GET, no waiting
    
    print(poller.status())                             # e.g. "running", "succeeded", "failed"
    
    if poller.polling_method().finished():           # succeeded, failed or canceled
    
        result = await poller.result()                 # returns immediately, no extra polling
    
        print(result.succeeded_count, result.failed_count, result.skipped_count)
    
    else:
    
        # not finished: put the message back on the queue and check again later
    
        ...
    
    

    finished() is also True for failed / canceled; await poller.result() then raises HttpResponseError with the error details, so wrap it in try/except if your queue worker should not crash.

    I checked this against azure-ai-documentintelligence 1.0.2 and azure-core 1.39.0 with a mocked service: before the call, done() is False and status() is InProgress with no request sent; after update_status(), status() is succeeded and finished() is True after exactly one GET; and when the job is still running, finished() stays False.

    Alternatives, if you prefer:

    • Use the sync client in the worker: its LROPoller polls in a background thread, so done() updates on its own.
    • Call the REST endpoint directly: GET {endpoint}/documentintelligence/documentModels/{modelId}/analyzeBatchResults/{resultId}?api-version=2024-11-30 returns status and percentCompleted.

    I've also added this explanation to the SDK issue you opened (Azure/azure-sdk-for-python#47972).

    If this answers your question, please accept the answer so others can find it.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.