Internal Server Error when calling Azure.AI.DocumentIntelligence.AnalyzeDocumentAsync with latest SDK

Sean Leino 20 Reputation points
2025-01-16T17:36:11.22+00:00

We have been successfully using the previous Azure.AI.FormRecognizer SDK v4.1 to call prebuilt models in Azure Document Intelligence. Since we now want to use some of the latest prebuilt models (like prebuilt-tax.us), we now have to upgrade to the newly released Azure.AI.DocumentIntelligence SDK v1.0. Problem is, when we use the new DocumentIntelligence SDK, we get back an Internal Server Error with no extra details indicating the cause of the problem. Code snippet which shows picking up a local file, passing it as a FileStream and calling AnalyzeDocumentAsync

using Azure.AI.DocumentIntelligence;

using (FileStream fs = new FileStream(filePath, FileMode.Open))

{

*`string exceptionMessage;`*

*`var result;`*

*`AnalyzeDocumentOptions analyzeDocumentOptions = new AnalyzeDocumentOptions("prebuilt-tax.us", BinaryData.FromStream(fs));`*

*`try`*

*`{`*

	*`Operation<AnalyzeResult> operation = client.AnalyzeDocumentAsync(WaitUntil.Completed, analyzeDocumentOptions).GetAwaiter().GetResult();`*

	*`result = operation.Value;`*

*`}`*

*`catch (Azure.RequestFailedException ex)`*

*`{`*

	*`exceptionMessage = $"Error Message {ex.Message}; Inner Message {ex.InnerException?.Message} String {ex.ToString()}";`*

*`}`*

}

The really strange part is that the information coming back from the exception is a mix of success and error, with the end result being a failed invocation:

Exception when calling Azure Document Intelligence API : Error Message An unexpected error occurred.

Status: 200 (OK)

ErrorCode: InternalServerError

Service request succeeded. Response content and headers are not included to avoid logging sensitive data.

; Inner Message String Azure.RequestFailedException: An unexpected error occurred.

Status: 200 (OK)

ErrorCode: InternalServerError

Service request succeeded. Response content and headers are not included to avoid logging sensitive data.

at Azure.Core.OperationInternal1.GetResponseFromState(OperationState1 state)

at Azure.Core.OperationInternal`1.<UpdateStatusAsync>d__20.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Azure.Core.ProtocolOperation`1.UpdateStatus(CancellationToken cancellationToken)

at Azure.AI.DocumentIntelligence.OperationWithId.UpdateStatus(CancellationToken cancellationToken)

at Azure.Core.OperationPoller.<WaitForCompletionAsync>d__10.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Azure.Core.OperationPoller.WaitForCompletionT

at Azure.Operation`1.WaitForCompletion(CancellationToken cancellationToken)

at Azure.AI.DocumentIntelligence.DocumentIntelligenceClient.AnalyzeDocument(WaitUntil waitUntil, String modelId, RequestContent content, String pages, String locale, String stringIndexType, IEnumerable1 features, IEnumerable1 queryFields, String outputContentFormat, IEnumerable`1 output, RequestContext context)

at Azure.AI.DocumentIntelligence.DocumentIntelligenceClient.AnalyzeDocument(WaitUntil waitUntil, AnalyzeDocumentOptions options, CancellationToken cancellationToken)

at Adapters.AzureAIDocIntelligenceV4.Adapter.<>c__DisplayClass25_1.<PerformRecognition>b__0() in Adapters.AzureAIDocIntelligenceV4\Adapter.cs:line 229...

Azure AI Document Intelligence
Azure AI Document Intelligence
An Azure service that turns documents into usable data. Previously known as Azure Form Recognizer.
1,895 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sina Salam 17,016 Reputation points
    2025-01-17T16:02:33.75+00:00

    Hello Sean Leino,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    I understand that you are having Internal Server Error when calling Azure.AI.DocumentIntelligence.AnalyzeDocumentAsync with latest SDK.

    This looks like common generic error, if you have tried to check Payload and File, SDK and Dependencies, Region and Service Availability, and if everything looks okay. Add a retry mechanism and logs the exception details, it will save you from future occurrence. You can also contact Microsoft Support via your portal to raise ticket if you're using a paid subscription.

    I hope this is helpful! Do not hesitate to let me know if you have any other questions.


    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

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.