Partager via


DocumentIntelligenceClient.AnalyzeBatchDocumentsAsync Method

Definition

Overloads

AnalyzeBatchDocumentsAsync(WaitUntil, AnalyzeBatchDocumentsOptions, CancellationToken)

Analyzes batch documents with document model.

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, AnalyzeBatchDocumentsOptions, 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, Azure.AI.DocumentIntelligence.AnalyzeBatchDocumentsOptions options, System.Threading.CancellationToken cancellationToken = default);
abstract member AnalyzeBatchDocumentsAsync : Azure.WaitUntil * Azure.AI.DocumentIntelligence.AnalyzeBatchDocumentsOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.AnalyzeBatchResult>>
override this.AnalyzeBatchDocumentsAsync : Azure.WaitUntil * Azure.AI.DocumentIntelligence.AnalyzeBatchDocumentsOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.AnalyzeBatchResult>>
Public Overridable Function AnalyzeBatchDocumentsAsync (waitUntil As WaitUntil, options As AnalyzeBatchDocumentsOptions, 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.

options
AnalyzeBatchDocumentsOptions

Analyze batch request options.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

options is null.

Examples

This sample shows how to call AnalyzeBatchDocumentsAsync.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
DocumentIntelligenceClient client = new DocumentIntelligenceClient(endpoint, credential);

AnalyzeBatchDocumentsOptions analyzeBatchRequest = new AnalyzeBatchDocumentsOptions(new Uri("https://myStorageAccount.blob.core.windows.net/myOutputContainer?mySasToken"))
{
    ResultPrefix = "trainingDocsResult/",
    OverwriteExisting = true,
};
Operation<AnalyzeBatchResult> operation = await client.AnalyzeBatchDocumentsAsync(WaitUntil.Completed, "customModel", analyzeBatchRequest);
AnalyzeBatchResult responseData = operation.Value;

Applies to

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
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

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("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
DocumentIntelligenceClient client = new DocumentIntelligenceClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    azureBlobSource = new
    {
        containerUrl = "https://myStorageAccount.blob.core.windows.net/myContainer?mySasToken",
        prefix = "trainingDocs/",
    },
    resultContainerUrl = "https://myStorageAccount.blob.core.windows.net/myOutputContainer?mySasToken",
    resultPrefix = "trainingDocsResult/",
    overwriteExisting = true,
});
Operation<BinaryData> operation = await client.AnalyzeBatchDocumentsAsync(WaitUntil.Completed, "customModel", 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());

Applies to