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(OperationState
1 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, IEnumerable
1 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...