Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.35k stars 4.71k forks source link

AnalyzeDocumentFromUriAsync Does not exist #44740

Closed dwainbrowne closed 2 months ago

dwainbrowne commented 3 months ago

Type of issue

Code doesn't work

Description

I'm very confused on which API I should be using using Azure.AI.DocumentIntelligence; using Azure.AI.FormRecognizer;

I tried the code sample provided, and it has no method called AnalyzeDocumentFromUriAsync

'DocumentIntelligenceClient' does not contain a definition for 'AnalyzeDocumentFromUriAsync' and no accessible extension method 'AnalyzeDocumentFromUriAsync' accepting a first argument of type 'DocumentIntelligenceClient' could be found (are you missing a using directive or an assembly reference?)CS1061

Sample code:

var client = new DocumentIntelligenceClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

        Console.WriteLine("Analyzing document from URL...");
        AnalyzeDocumentOperation operation = await client.AnalyzeDocumentFromUriAsync(WaitUntil.Completed, "prebuilt-layout", fileUri);
        AnalyzeResult result = operation.Value;

        foreach (DocumentPage page in result.Pages)
        {
            Console.WriteLine($"Document Page {page.PageNumber} has {page.Lines.Count} line(s), {page.Words.Count} word(s),");
            Console.WriteLine($"and {page.SelectionMarks.Count} selection mark(s).");

            for (int i = 0; i < page.Lines.Count; i++)
            {
                DocumentLine line = page.Lines[i];
                Console.WriteLine($"  Line {i} has content: '{line.Content}'.");

                Console.WriteLine($"    Its bounding polygon (points ordered clockwise):");

                for (int j = 0; j < line.BoundingPolygon.Count; j++)
                {
                    Console.WriteLine($"      Point {j} => X: {line.BoundingPolygon[j].X}, Y: {line.BoundingPolygon[j].Y}");
                }
            }

Page URL

https://learn.microsoft.com/en-us/dotnet/api/overview/azure/ai.formrecognizer-readme?view=azure-dotnet

Content source URL

https://github.com/Azure/azure-docs-sdk-dotnet/blob/master/api/overview/azure/latest/ai.formrecognizer-readme.md

Document Version Independent Id

ed88679a-395f-a658-010c-4fdeea56eade

Article author

@azure-sdk

Metadata

jsquire commented 3 months ago

Thank you for your feedback. Tagging and routing to the team member best able to assist.

kinelski commented 3 months ago

Hello @dwainbrowne,

The Document Intelligence service has gone through a lot of changes in the last couple of years, some of them causing major changes to the design of the SDK. Because of this, we currently have two libraries supporting this service: Azure.AI.DocumentIntelligence, and Azure.AI.FormRecognizer.

Azure.AI.DocumentIntelligence

This is the newer library, and currently it only supports the latest version released by the Document Intelligence service (2024-02-29-preview). From now on, this is the only library we'll be updating with new service features. If you haven't worked with the SDK before, this is the library we recommend going forward.

When using this library, you'll be using the Azure.AI.DocumentIntelligence namespace, and both the DocumentIntelligenceClient and the DocumentIntelligenceAdministrationClient.

Please note that Azure.AI.DocumentIntelligence is still in beta, so breaking changes are expected until version 1.0.0 is released.

Azure.AI.FormRecognizer

This is the first library we released, when the Document Intelligence service was still named Form Recognizer. Going forward, we won't be supporting this library anymore. The latest service version it supports is 2023-07-31, and it won't be updated to include new versions in the future.

When using it, you'll be using the Azure.AI.FormRecognizer.DocumentAnalysis namespace, and both the DocumentAnalysisClient and the DocumentModelAdministrationClient.

It's worth mentioning that this library also contains an Azure.AI.FormRecognizer namespace that was used for still older service versions, but we don't recommend using them anymore.

I hope that helps. Feel free to let us know if you have more questions.

kinelski commented 3 months ago

@dwainbrowne Just to clarify, the snippet code you shared uses the old Azure.AI.FormRecognizer library.

To do the same with the new Azure.AI.DocumentIntelligence library, please follow this sample: Analyze a document with a prebuilt model

github-actions[bot] commented 3 months ago

Hi @dwainbrowne. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text "/unresolve" to remove the "issue-addressed" label and continue the conversation.

github-actions[bot] commented 2 months ago

Hi @dwainbrowne, since you haven’t asked that we /unresolve the issue, we’ll close this out. If you believe further discussion is needed, please add a comment /unresolve to reopen the issue.