Я проверил ключ API и конечная точка API с ведением журнала, и они верны.
Я использую Azure.AI.DocumentIntelligence" Version="1.0.0-beta.3" "
Код: Выделить всё
async Task AnalyzeDocumentAsync(string filePath)
{
var config = ((IConfigurationRoot)_config).GetRequiredSection("DocumentIntelligence").Get();
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
Подробнее здесь: https://stackoverflow.com/questions/790 ... t-to-azure
Мобильная версия