我们在使用发票 Azure 表单识别器容器时遇到了困难。在我们发送文档进行处理后,我们会收到“失败”状态。我们尝试了两种方式发送:application/json 和 application/octet-stream,但总是出现错误。
具体来说,这是一个响应示例:
{
"status": "failed",
"createdDateTime": "2024-01-02T15:53:56Z",
"lastUpdatedDateTime": "2024-01-02T15:53:56Z",
"error": {
"code": "InternalServerError",
"message": "An unexpected error occurred.",
"details": [
{
"code": "HttpRequestException",
"message": "Could not connect to upstream host: An invalid request URI was provided. Either the request URI must be an absolute URI or BaseAddress must be set.",
"target": "1"
}
]
}
}
我们启动这个容器的方式:
~$ dockerun --rm -it -p 5000:5050 --memory 16g --cpus 6 -e Eula=accept -e Billing=https://xxxx.cognitiveservices.azure.com -e ApiKey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx mcr.microsoft.com/azure-cognitive-services/form-recognizer/invoice-3.0
控制台显示错误:
fail: formrecognizerinvoice[0]
{"ClassName":"Microsoft.CloudAI.Containers.VDI.Common.Errors.VdiException","Message":"HttpRequestException","Data":null,"InnerException":null,"HelpURL":null,"StackTraceString":" at Microsoft.CloudAI.Containers.VDI.OnPremises.Common.Handler.FrBaseHandler.HttpPostAsync(String requestUri, HttpContent content)\n at Microsoft.CloudAI.Containers.VDI.OnPremises.Common.Handler.Fr30GaUpstreamHandler.PostUpstreamInternalRequest(String modelId, Byte[] stream, ServiceMessage message)\n at Microsoft.CloudAI.Containers.VDI.OnPremises.Common.Handler.Fr30GaUpstreamHandler.HandleMessageAsync(ServiceMessage message)","RemoteStackTraceString":null,"RemoteStackIndex":0,"ExceptionMethod":null,"HResult":-2146233088,"Source":"Microsoft.CloudAI.Containers.VDI.OnPremises.Common","WatsonBuckets":null} SubscriptionId='' RequestId='ebab790b-3e6e-4c0b-af93-9396cb609fd8' Timestamp='' buildVersion='1.2.367.0-20230707.6-27dcd7ae972075713bb9e4477fe50c6e623f1596' hostId='a71ffbc4bc9f' serviceName='formrecognizerinvoice' namespace='vdi' Namesapce='vdi' fileSizeInBytes='100040' processedPageIndex='0' toSecondaryQueue='False' totalPageCount='2' fileType='Pdf' apiName='invoice-2022-08-31' ocrModelName='2023-07-31' scenario='fr_async_layout' resultNameEnum='UpstreamFRResult' ocrResolution='Standard' errorCode='HttpRequestException'
我们如何解决这个问题?
我们正在使用另一个容器测试同一文件:布局表单识别器,它工作正常。
根据文档,
Invoice
功能容器需要支持Layout
容器。
因此,该问题可能是由于您在不支持布局容器的情况下启动容器,并且可以通过在请求中包含支持容器来解决。
下面是一个示例 YAML
invoice
配置供参考:
version: "3.9"
services:
azure-cognitive-service-invoice:
container_name: azure-cognitive-service-invoice
image: mcr.microsoft.com/azure-cognitive-services/form-recognizer/invoice-3.0
environment:
- EULA=accept
- billing={FORM_RECOGNIZER_ENDPOINT_URI}
- apiKey={FORM_RECOGNIZER_KEY}
- AzureCognitiveServiceLayoutHost=http://azure-cognitive-service-layout:5000
ports:
- "5000:5050"
azure-cognitive-service-layout:
container_name: azure-cognitive-service-layout
image: mcr.microsoft.com/azure-cognitive-services/form-recognizer/layout-3.0
environment:
- EULA=accept
- billing={FORM_RECOGNIZER_ENDPOINT_URI}
- apiKey={FORM_RECOGNIZER_KEY}