Is it only possible to use Form Recognizer v3.0 with a URI?

ryota.matsuda 140 Reputation points

I have tried Form Recgnizer with WindowsFormAPP with this C# clickstart. The accuracy is good and we are considering commercializing it.

I would like to ask a question here.

The documentation says "Requires the document file specified by URI".

Is it only possible to use Form Recognizer v3.0 with a URI? Is it impossible to have an image or pdf in a local file path?

I believe it is common to upload a pdf or png image, such as a local file in Explorer, to the screen for OCR processing.

Surely the AnalyzeDocumentFromUriAsync method must be passed a URI.

If there is another method that can pass a local path, I would appreciate a sample.

Translated with (free version)

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,605 questions
Azure AI Document Intelligence
Azure AI Document Intelligence
An Azure service that turns documents into usable data. Previously known as Azure Form Recognizer.
1,522 questions
{count} votes

Accepted answer
  1. romungi-MSFT 43,681 Reputation points Microsoft Employee

    @ryota.matsuda To analyze a local document you will have to use AnalyzeDocumentAsync() method. Here is a sample that you could use for this method.

    string modelId = "<modelId>";
    string filePath = "<filePath>";
    using var stream = new FileStream(filePath, FileMode.Open);
    AnalyzeDocumentOperation operation = await client.AnalyzeDocumentAsync(WaitUntil.Completed, modelId, stream);
    AnalyzeResult result = operation.Value;
    Console.WriteLine($"Document was analyzed with model with ID: {result.ModelId}");
    foreach (AnalyzedDocument document in result.Documents)
        Console.WriteLine($"Document of type: {document.DocumentType}");
        foreach (KeyValuePair<string, DocumentField> fieldKvp in document.Fields)
            string fieldName = fieldKvp.Key;
            DocumentField field = fieldKvp.Value;
            Console.WriteLine($"Field '{fieldName}': ");
            Console.WriteLine($"  Content: '{field.Content}'");
            Console.WriteLine($"  Confidence: '{field.Confidence}'");

    The github repo provides more samples on this method and other pre-built models for reference.

    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

0 additional answers

Sort by: Most helpful