Share via


DocumentIntelligenceClient.AnalyzeBatchDocumentsAsync Method

Definition

Overloads

AnalyzeBatchDocumentsAsync(WaitUntil, String, AnalyzeBatchDocumentsContent, String, String, Nullable<StringIndexType>, IEnumerable<DocumentAnalysisFeature>, IEnumerable<String>, Nullable<ContentFormat>, IEnumerable<AnalyzeOutputOption>, CancellationToken)

Analyzes batch documents with document model.

AnalyzeBatchDocumentsAsync(WaitUntil, String, RequestContent, String, String, String, IEnumerable<DocumentAnalysisFeature>, IEnumerable<String>, String, IEnumerable<AnalyzeOutputOption>, RequestContext)

[Protocol Method] Analyzes batch documents with document model.

AnalyzeBatchDocumentsAsync(WaitUntil, String, AnalyzeBatchDocumentsContent, String, String, Nullable<StringIndexType>, IEnumerable<DocumentAnalysisFeature>, IEnumerable<String>, Nullable<ContentFormat>, IEnumerable<AnalyzeOutputOption>, CancellationToken)

Source:
DocumentIntelligenceClient.cs

Analyzes batch documents with document model.

public virtual System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.AnalyzeBatchResult>> AnalyzeBatchDocumentsAsync (Azure.WaitUntil waitUntil, string modelId, Azure.AI.DocumentIntelligence.AnalyzeBatchDocumentsContent analyzeBatchRequest = default, string pages = default, string locale = default, Azure.AI.DocumentIntelligence.StringIndexType? stringIndexType = default, System.Collections.Generic.IEnumerable<Azure.AI.DocumentIntelligence.DocumentAnalysisFeature> features = default, System.Collections.Generic.IEnumerable<string> queryFields = default, Azure.AI.DocumentIntelligence.ContentFormat? outputContentFormat = default, System.Collections.Generic.IEnumerable<Azure.AI.DocumentIntelligence.AnalyzeOutputOption> output = default, System.Threading.CancellationToken cancellationToken = default);
abstract member AnalyzeBatchDocumentsAsync : Azure.WaitUntil * string * Azure.AI.DocumentIntelligence.AnalyzeBatchDocumentsContent * string * string * Nullable<Azure.AI.DocumentIntelligence.StringIndexType> * seq<Azure.AI.DocumentIntelligence.DocumentAnalysisFeature> * seq<string> * Nullable<Azure.AI.DocumentIntelligence.ContentFormat> * seq<Azure.AI.DocumentIntelligence.AnalyzeOutputOption> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.AnalyzeBatchResult>>
override this.AnalyzeBatchDocumentsAsync : Azure.WaitUntil * string * Azure.AI.DocumentIntelligence.AnalyzeBatchDocumentsContent * string * string * Nullable<Azure.AI.DocumentIntelligence.StringIndexType> * seq<Azure.AI.DocumentIntelligence.DocumentAnalysisFeature> * seq<string> * Nullable<Azure.AI.DocumentIntelligence.ContentFormat> * seq<Azure.AI.DocumentIntelligence.AnalyzeOutputOption> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.AnalyzeBatchResult>>
Public Overridable Function AnalyzeBatchDocumentsAsync (waitUntil As WaitUntil, modelId As String, Optional analyzeBatchRequest As AnalyzeBatchDocumentsContent = Nothing, Optional pages As String = Nothing, Optional locale As String = Nothing, Optional stringIndexType As Nullable(Of StringIndexType) = Nothing, Optional features As IEnumerable(Of DocumentAnalysisFeature) = Nothing, Optional queryFields As IEnumerable(Of String) = Nothing, Optional outputContentFormat As Nullable(Of ContentFormat) = Nothing, Optional output As IEnumerable(Of AnalyzeOutputOption) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Operation(Of AnalyzeBatchResult))

Parameters

waitUntil
WaitUntil

Completed if the method should wait to return until the long-running operation has completed on the service; Started if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.

modelId
String

Unique document model name.

analyzeBatchRequest
AnalyzeBatchDocumentsContent

Analyze batch request parameters.

pages
String

List of 1-based page numbers to analyze. Ex. "1-3,5,7-9".

locale
String

Locale hint for text recognition and document analysis. Value may contain only the language code (ex. "en", "fr") or BCP 47 language tag (ex. "en-US").

stringIndexType
Nullable<StringIndexType>

Method used to compute string offset and length.

features
IEnumerable<DocumentAnalysisFeature>

List of optional analysis features.

queryFields
IEnumerable<String>

List of additional fields to extract. Ex. "NumberOfGuests,StoreNumber".

outputContentFormat
Nullable<ContentFormat>

Format of the analyze result top-level content.

output
IEnumerable<AnalyzeOutputOption>

Additional outputs to generate during analysis.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

modelId is null.

modelId is an empty string, and was expected to be non-empty.

Examples

This sample shows how to call AnalyzeBatchDocumentsAsync.

Uri endpoint = new Uri("<https://my-service.azure.com>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
DocumentIntelligenceClient client = new DocumentIntelligenceClient(endpoint, credential);

Operation<AnalyzeBatchResult> operation = await client.AnalyzeBatchDocumentsAsync(WaitUntil.Completed, "<modelId>");
AnalyzeBatchResult responseData = operation.Value;

This sample shows how to call AnalyzeBatchDocumentsAsync with all parameters.

Uri endpoint = new Uri("<https://my-service.azure.com>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
DocumentIntelligenceClient client = new DocumentIntelligenceClient(endpoint, credential);

AnalyzeBatchDocumentsContent analyzeBatchRequest = new AnalyzeBatchDocumentsContent(new Uri("http://localhost:3000"))
{
    AzureBlobSource = new AzureBlobContentSource(new Uri("http://localhost:3000"))
    {
        Prefix = "<prefix>",
    },
    AzureBlobFileListSource = new AzureBlobFileListContentSource(new Uri("http://localhost:3000"), "<fileList>"),
    ResultPrefix = "<resultPrefix>",
    OverwriteExisting = true,
};
Operation<AnalyzeBatchResult> operation = await client.AnalyzeBatchDocumentsAsync(WaitUntil.Completed, "<modelId>", analyzeBatchRequest: analyzeBatchRequest, pages: "<pages>", locale: "<locale>", stringIndexType: StringIndexType.TextElements, features: new DocumentAnalysisFeature[] { DocumentAnalysisFeature.OcrHighResolution }, queryFields: new string[] { "<queryFields>" }, outputContentFormat: ContentFormat.Text, output: new AnalyzeOutputOption[] { AnalyzeOutputOption.Pdf });
AnalyzeBatchResult responseData = operation.Value;

Applies to

AnalyzeBatchDocumentsAsync(WaitUntil, String, RequestContent, String, String, String, IEnumerable<DocumentAnalysisFeature>, IEnumerable<String>, String, IEnumerable<AnalyzeOutputOption>, RequestContext)

Source:
DocumentIntelligenceClient.cs

[Protocol Method] Analyzes batch documents with document model.

public virtual System.Threading.Tasks.Task<Azure.Operation<BinaryData>> AnalyzeBatchDocumentsAsync (Azure.WaitUntil waitUntil, string modelId, Azure.Core.RequestContent content, string pages = default, string locale = default, string stringIndexType = default, System.Collections.Generic.IEnumerable<Azure.AI.DocumentIntelligence.DocumentAnalysisFeature> features = default, System.Collections.Generic.IEnumerable<string> queryFields = default, string outputContentFormat = default, System.Collections.Generic.IEnumerable<Azure.AI.DocumentIntelligence.AnalyzeOutputOption> output = default, Azure.RequestContext context = default);
abstract member AnalyzeBatchDocumentsAsync : Azure.WaitUntil * string * Azure.Core.RequestContent * string * string * string * seq<Azure.AI.DocumentIntelligence.DocumentAnalysisFeature> * seq<string> * string * seq<Azure.AI.DocumentIntelligence.AnalyzeOutputOption> * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Operation<BinaryData>>
override this.AnalyzeBatchDocumentsAsync : Azure.WaitUntil * string * Azure.Core.RequestContent * string * string * string * seq<Azure.AI.DocumentIntelligence.DocumentAnalysisFeature> * seq<string> * string * seq<Azure.AI.DocumentIntelligence.AnalyzeOutputOption> * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Operation<BinaryData>>
Public Overridable Function AnalyzeBatchDocumentsAsync (waitUntil As WaitUntil, modelId As String, content As RequestContent, Optional pages As String = Nothing, Optional locale As String = Nothing, Optional stringIndexType As String = Nothing, Optional features As IEnumerable(Of DocumentAnalysisFeature) = Nothing, Optional queryFields As IEnumerable(Of String) = Nothing, Optional outputContentFormat As String = Nothing, Optional output As IEnumerable(Of AnalyzeOutputOption) = Nothing, Optional context As RequestContext = Nothing) As Task(Of Operation(Of BinaryData))

Parameters

waitUntil
WaitUntil

Completed if the method should wait to return until the long-running operation has completed on the service; Started if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.

modelId
String

Unique document model name.

content
RequestContent

The content to send as the body of the request.

pages
String

List of 1-based page numbers to analyze. Ex. "1-3,5,7-9".

locale
String

Locale hint for text recognition and document analysis. Value may contain only the language code (ex. "en", "fr") or BCP 47 language tag (ex. "en-US").

stringIndexType
String

Method used to compute string offset and length. Allowed values: "textElements" | "unicodeCodePoint" | "utf16CodeUnit".

features
IEnumerable<DocumentAnalysisFeature>

List of optional analysis features.

queryFields
IEnumerable<String>

List of additional fields to extract. Ex. "NumberOfGuests,StoreNumber".

outputContentFormat
String

Format of the analyze result top-level content. Allowed values: "text" | "markdown".

output
IEnumerable<AnalyzeOutputOption>

Additional outputs to generate during analysis.

context
RequestContext

The request context, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The Operation representing an asynchronous operation on the service.

Exceptions

modelId is null.

modelId is an empty string, and was expected to be non-empty.

Service returned a non-success status code.

Examples

This sample shows how to call AnalyzeBatchDocumentsAsync and parse the result.

Uri endpoint = new Uri("<https://my-service.azure.com>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
DocumentIntelligenceClient client = new DocumentIntelligenceClient(endpoint, credential);

using RequestContent content = null;
Operation<BinaryData> operation = await client.AnalyzeBatchDocumentsAsync(WaitUntil.Completed, "<modelId>", content);
BinaryData responseData = operation.Value;

JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement;
Console.WriteLine(result.GetProperty("succeededCount").ToString());
Console.WriteLine(result.GetProperty("failedCount").ToString());
Console.WriteLine(result.GetProperty("skippedCount").ToString());
Console.WriteLine(result.GetProperty("details")[0].GetProperty("status").ToString());
Console.WriteLine(result.GetProperty("details")[0].GetProperty("sourceUrl").ToString());

This sample shows how to call AnalyzeBatchDocumentsAsync with all parameters and request content and parse the result.

Uri endpoint = new Uri("<https://my-service.azure.com>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
DocumentIntelligenceClient client = new DocumentIntelligenceClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    azureBlobSource = new
    {
        containerUrl = "http://localhost:3000",
        prefix = "<prefix>",
    },
    azureBlobFileListSource = new
    {
        containerUrl = "http://localhost:3000",
        fileList = "<fileList>",
    },
    resultContainerUrl = "http://localhost:3000",
    resultPrefix = "<resultPrefix>",
    overwriteExisting = true,
});
Operation<BinaryData> operation = await client.AnalyzeBatchDocumentsAsync(WaitUntil.Completed, "<modelId>", content, pages: "<pages>", locale: "<locale>", stringIndexType: "textElements", features: new DocumentAnalysisFeature[] { DocumentAnalysisFeature.OcrHighResolution }, queryFields: new string[] { "<queryFields>" }, outputContentFormat: "text", output: new AnalyzeOutputOption[] { AnalyzeOutputOption.Pdf });
BinaryData responseData = operation.Value;

JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement;
Console.WriteLine(result.GetProperty("succeededCount").ToString());
Console.WriteLine(result.GetProperty("failedCount").ToString());
Console.WriteLine(result.GetProperty("skippedCount").ToString());
Console.WriteLine(result.GetProperty("details")[0].GetProperty("status").ToString());
Console.WriteLine(result.GetProperty("details")[0].GetProperty("sourceUrl").ToString());
Console.WriteLine(result.GetProperty("details")[0].GetProperty("resultUrl").ToString());
Console.WriteLine(result.GetProperty("details")[0].GetProperty("error").GetProperty("code").ToString());
Console.WriteLine(result.GetProperty("details")[0].GetProperty("error").GetProperty("message").ToString());
Console.WriteLine(result.GetProperty("details")[0].GetProperty("error").GetProperty("target").ToString());
Console.WriteLine(result.GetProperty("details")[0].GetProperty("error").GetProperty("innererror").GetProperty("code").ToString());
Console.WriteLine(result.GetProperty("details")[0].GetProperty("error").GetProperty("innererror").GetProperty("message").ToString());

Applies to