部署到azure后文档智能不起作用

问题描述 投票:0回答:1

我有一个 asp.net Web 应用程序,其代码可在本地系统(Mac OS)中运行,但在部署后无法在 Azure Web App(Linux)中运行。

我通过日志记录检查了 api 密钥和 api 端点,它们是正确的。

我正在使用 Azure.AI.DocumentIntelligence" Version="1.0.0-beta.3"

            async Task<AnalyzeDocumentResult> AnalyzeDocumentAsync(string filePath)
            {

                var config = ((IConfigurationRoot)_config).GetRequiredSection("DocumentIntelligence").Get<DocumentIntelligenceConfig>();
                var credential = new AzureKeyCredential(config?.ApiKey ?? string.Empty);

                var options = new DocumentIntelligenceClientOptions(DocumentIntelligenceClientOptions.ServiceVersion.V2024_07_31_Preview);
                var client = new DocumentIntelligenceClient(new Uri(config?.EndPoint ?? string.Empty), credential, options);

                var file = new AnalyzeDocumentContent()
                    {
                        Base64Source = BinaryData.FromBytes(await File.ReadAllBytesAsync(filePath))
                    };

                var operation = await client.AnalyzeDocumentAsync(WaitUntil.Completed, "prebuilt-layout", file.Content, outputContentFormat: ContentFormat.Markdown);

                if (!operation.HasValue)
                {
                    _logger.LogError($"File doesn't have data: trackingCode: {trackingCode}");
                    return new AnalyzeDocumentResult(false, file.FilePath, null);
                }
                if (!operation.HasCompleted)
                {
                    _logger.LogError($"File doesn't completed: trackingCode: {trackingCode}");
                    return new AnalyzeDocumentResult(false, file.FilePath, null);
                }
                await File.WriteAllTextAsync(file.FilePath.Replace(".pdf", ".md"), operation.Value.Content);
                return new AnalyzeDocumentResult(true, file.FilePath, operation.Value.Content);
            }

我收到以下错误:

AnalyzeFileAsync -> Resource not found
Status: 404 (Not Found)
ErrorCode: 404

Content:
{"error":{"code":"404","message":"Resource not found"}}

Headers:
Date: Tue, 01 Oct 2024 20:43:28 GMT
Content-Length: 55
Content-Type: application/json

这真的很奇怪,为什么它应该在本地工作,但发布后却不起作用!有什么区别?

c# azure azure-cognitive-services azure-sdk azure-form-recognizer
1个回答
0
投票

我不确定这是否与此存储库直接相关,但我遇到的问题是德国中西部地区。在西欧重新部署 Doc Intelligence 后,现在一切正常!

我找不到任何解释地区之间差异或具体问题的文档。如果其他人也面临类似的问题,请考虑重新部署到其他区域,因为这可能会解决问题。

© www.soinside.com 2019 - 2024. All rights reserved.