Condividi tramite


DocumentIntelligenceAdministrationClient.BuildDocumentModelAsync Method

Definition

Overloads

BuildDocumentModelAsync(WaitUntil, BuildDocumentModelOptions, CancellationToken)

Builds a custom document analysis model.

BuildDocumentModelAsync(WaitUntil, BuildDocumentModelContent, CancellationToken)

Builds a custom document analysis model.

BuildDocumentModelAsync(WaitUntil, RequestContent, RequestContext)

[Protocol Method] Builds a custom document analysis model.

BuildDocumentModelAsync(WaitUntil, BuildDocumentModelOptions, CancellationToken)

Source:
DocumentIntelligenceAdministrationClient.cs

Builds a custom document analysis model.

public virtual System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.DocumentModelDetails>> BuildDocumentModelAsync (Azure.WaitUntil waitUntil, Azure.AI.DocumentIntelligence.BuildDocumentModelOptions options, System.Threading.CancellationToken cancellationToken = default);
abstract member BuildDocumentModelAsync : Azure.WaitUntil * Azure.AI.DocumentIntelligence.BuildDocumentModelOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.DocumentModelDetails>>
override this.BuildDocumentModelAsync : Azure.WaitUntil * Azure.AI.DocumentIntelligence.BuildDocumentModelOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.DocumentModelDetails>>
Public Overridable Function BuildDocumentModelAsync (waitUntil As WaitUntil, options As BuildDocumentModelOptions, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Operation(Of DocumentModelDetails))

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
BuildDocumentModelOptions

Build request options.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

options is null.

Examples

This sample shows how to call BuildDocumentModelAsync.

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

BuildDocumentModelOptions buildRequest = new BuildDocumentModelOptions("myCustomModel", DocumentBuildMode.Template)
{
    Description = "Custom model description",
    Tags =
    {
        ["createdBy"] = "myUserId"
    },
};
Operation<DocumentModelDetails> operation = await client.BuildDocumentModelAsync(WaitUntil.Completed, buildRequest);
DocumentModelDetails responseData = operation.Value;

Applies to

BuildDocumentModelAsync(WaitUntil, BuildDocumentModelContent, CancellationToken)

Source:
DocumentIntelligenceAdministrationClient.cs

Builds a custom document analysis model.

public virtual System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.DocumentModelDetails>> BuildDocumentModelAsync (Azure.WaitUntil waitUntil, Azure.AI.DocumentIntelligence.BuildDocumentModelContent buildRequest, System.Threading.CancellationToken cancellationToken = default);
abstract member BuildDocumentModelAsync : Azure.WaitUntil * Azure.AI.DocumentIntelligence.BuildDocumentModelContent * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.DocumentModelDetails>>
override this.BuildDocumentModelAsync : Azure.WaitUntil * Azure.AI.DocumentIntelligence.BuildDocumentModelContent * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.DocumentModelDetails>>
Public Overridable Function BuildDocumentModelAsync (waitUntil As WaitUntil, buildRequest As BuildDocumentModelContent, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Operation(Of DocumentModelDetails))

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.

buildRequest
BuildDocumentModelContent

Build request parameters.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

buildRequest is null.

Examples

This sample shows how to call BuildDocumentModelAsync.

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

BuildDocumentModelContent buildRequest = new BuildDocumentModelContent("<modelId>", DocumentBuildMode.Template);
Operation<DocumentModelDetails> operation = await client.BuildDocumentModelAsync(WaitUntil.Completed, buildRequest);
DocumentModelDetails responseData = operation.Value;

This sample shows how to call BuildDocumentModelAsync with all parameters.

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

BuildDocumentModelContent buildRequest = new BuildDocumentModelContent("<modelId>", DocumentBuildMode.Template)
{
    Description = "<description>",
    AzureBlobSource = new AzureBlobContentSource(new Uri("http://localhost:3000"))
    {
        Prefix = "<prefix>",
    },
    AzureBlobFileListSource = new AzureBlobFileListContentSource(new Uri("http://localhost:3000"), "<fileList>"),
    Tags =
    {
        ["key"] = "<tags>"
    },
    MaxTrainingHours = 123.45F,
    AllowOverwrite = true,
};
Operation<DocumentModelDetails> operation = await client.BuildDocumentModelAsync(WaitUntil.Completed, buildRequest);
DocumentModelDetails responseData = operation.Value;

Applies to

BuildDocumentModelAsync(WaitUntil, RequestContent, RequestContext)

Source:
DocumentIntelligenceAdministrationClient.cs
Source:
DocumentIntelligenceAdministrationClient.cs

[Protocol Method] Builds a custom document analysis model.

public virtual System.Threading.Tasks.Task<Azure.Operation<BinaryData>> BuildDocumentModelAsync (Azure.WaitUntil waitUntil, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member BuildDocumentModelAsync : Azure.WaitUntil * Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Operation<BinaryData>>
override this.BuildDocumentModelAsync : Azure.WaitUntil * Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Operation<BinaryData>>
Public Overridable Function BuildDocumentModelAsync (waitUntil As WaitUntil, content As RequestContent, 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.

content
RequestContent

The content to send as the body of the request.

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

content is null.

Service returned a non-success status code.

Examples

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

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

using RequestContent content = RequestContent.Create(new
{
    modelId = "myCustomModel",
    description = "Custom model description",
    buildMode = "template",
    azureBlobSource = new
    {
        containerUrl = "https://myStorageAccount.blob.core.windows.net/myContainer?mySasToken",
        prefix = "trainingDocs/",
    },
    tags = new
    {
        createdBy = "myUserId",
    },
});
Operation<BinaryData> operation = await client.BuildDocumentModelAsync(WaitUntil.Completed, content);
BinaryData responseData = operation.Value;

JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement;
Console.WriteLine(result.GetProperty("modelId").ToString());
Console.WriteLine(result.GetProperty("createdDateTime").ToString());

Applies to