skip to Main Content

I have asp.net web app with following code which works in local system (Mac OS) but didn’t work in Azure Web App (Linux) after deployment.

I checked the api key and api endpoint with logging and they are correct.

I’m using 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);
            }

I receive the following error:

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

It’s really weird, why it should works locally but not after publish! What is the difference?

2

Answers


  1. Chosen as BEST ANSWER

    I'm not sure if this is directly related to this repository, but the issue I encountered was with the Germany West Central region. After redeploying Doc Intelligence in West Europe, everything is working fine now!

    I couldn't find any documentation explaining the differences or specific issues between regions. If anyone else is facing a similar problem, consider redeploying to a different region, as it might resolve the issue.


  2. Yes, the problem you encoutred is due to deploying Doc Intelligence in unsupported Azure region.

    It’s specified in the Azure AI Document Intelligence documentation that the 2024-07-31-preview version is currently available only in the following Azure regions:

    • East US
    • West US2
    • West Europe
    • North Central US
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search