How to deal with 500 errors on Azure Document Intelligence APIs

Andrei Pruteanu 0 Reputation points
2025-07-04T07:16:02.9633333+00:00

We encountered several errors like this:

File "/home/app/azure/core/polling/base_polling.py", line 803, in run raise HttpResponseError(response=self._pipeline_response.http_response, error=err) from err azure.core.exceptions.HttpResponseError: (InternalServerError) An unexpected error occurred. Code: InternalServerError Message: An unexpected error occurred. Exception Details: (InternalServerError) An unexpected error occurred. Code: InternalServerError Message: An unexpected error occurred. Target: 0

How should we deal with them? Does the API client have a retry mechanism builtin or we have to implement one as a wrapper?
Here is a more extensive log:

Traceback (most recent call last):
  File "/home/app/azure/core/polling/base_polling.py", line 788, in run
    self._poll()
  File "/home/app/azure/core/polling/base_polling.py", line 820, in _poll
    raise OperationFailed("Operation failed or canceled")
azure.core.polling.base_polling.OperationFailed: Operation failed or canceled  The above exception was the direct cause of the following exception:  Traceback (most recent call last):   File "bla1.py", line 647, in run     self.__process()   File "bla2.py", line 209, in __process     self.azure_client.extract()   File "bla.py", line 213, in extract
    azure_response = poller.result()
                     ^^^^^^^^^^^^^^^
  File "/home/app/azure/core/polling/_poller.py", line 254, in result
    self.wait(timeout)
  File "/home/app/azure/core/tracing/decorator.py", line 105, in wrapper_use_tracer
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/azure/core/polling/_poller.py", line 273, in wait
    raise self._exception  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^
  File "/home/app/azure/core/polling/_poller.py", line 188, in _start
    self._polling_method.run()
  File "/home/app/azure/core/polling/base_polling.py", line 803, in run
    raise HttpResponseError(response=self._pipeline_response.http_response, error=err) from err
azure.core.exceptions.HttpResponseError: (InternalServerError) An unexpected error occurred.
Code: InternalServerError
Message: An unexpected error occurred.
Exception Details:	(InternalServerError) An unexpected error occurred.
	Code: InternalServerError
	Message: An unexpected error occurred.
	Target: 0
	
	
	
processing.ocr_error

Azure AI Document Intelligence
Azure AI Document Intelligence
An Azure service that turns documents into usable data. Previously known as Azure Form Recognizer.
2,137 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Manas Mohanty 6,530 Reputation points Microsoft External Staff Moderator
    2025-07-04T08:09:50.4066667+00:00

    Hi Andrei Pruteanu

    You can switch to other available region in case of 500 internal server error.

    Regional support for all Azure services

    If it is a custom model, you can use copy authorization to copy the model to another document intelligence resource (different region)

    You might need to implement custom retry logic, but in case of 500 error, it is better to switch to another resource, Retries are more fruitful in case of 429 rate limit errors

        for retry_attemp in range(retry_count):
            try:
                results = await poller.result()
                success = True
            except Exception as ex:
                logger.error(f"Attempt {retry_attemp}: GET Exception {ex}")
                await asyncio.sleep(retry_sleep)
                token = poller.continuation_token()
                poller = await client.begin_analyze_document_from_url(
                    None, None, continuation_token=token
                )
                continue
    
    
    

    Reference for retry logic- https://github.com/Azure/azure-sdk-for-python/issues/35952#issuecomment-2168864017

    Other areas are to check are

    1. Permission (Cognitive Services user)
    2. Change in network configuration (Please check you have subnet/join permission on virtual network if document intelligence source moved to virtual network)
    3. Please check from metrics tab if you have exhausted your quota. Service limits, Troubleshoot latency issues
    4. Any policy related blocks can be checked in activity logs or application insights.

    Hope it helps

    Thank you.

    0 comments No comments

Your answer

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