Share via


DocumentIntelligenceAdministrationClient.CopyModelToAsync Method

Definition

Overloads

CopyModelToAsync(WaitUntil, String, RequestContent, RequestContext)

[Protocol Method] Copies document model to the target resource, region, and modelId.

CopyModelToAsync(WaitUntil, String, CopyAuthorization, CancellationToken)

Copies document model to the target resource, region, and modelId.

CopyModelToAsync(WaitUntil, String, RequestContent, RequestContext)

Source:
DocumentIntelligenceAdministrationClient.cs

[Protocol Method] Copies document model to the target resource, region, and modelId.

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

modelId
String

Unique document model name.

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

modelId or content 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 CopyModelToAsync and parse the result.

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

using RequestContent content = RequestContent.Create(new
{
    targetResourceId = "<targetResourceId>",
    targetResourceRegion = "<targetResourceRegion>",
    targetModelId = "<targetModelId>",
    targetModelLocation = "http://localhost:3000",
    accessToken = "<accessToken>",
    expirationDateTime = "2022-05-10T18:57:31.2311892Z",
});
Operation<BinaryData> operation = await client.CopyModelToAsync(WaitUntil.Completed, "<modelId>", content);
BinaryData responseData = operation.Value;

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

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

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

using RequestContent content = RequestContent.Create(new
{
    targetResourceId = "<targetResourceId>",
    targetResourceRegion = "<targetResourceRegion>",
    targetModelId = "<targetModelId>",
    targetModelLocation = "http://localhost:3000",
    accessToken = "<accessToken>",
    expirationDateTime = "2022-05-10T18:57:31.2311892Z",
});
Operation<BinaryData> operation = await client.CopyModelToAsync(WaitUntil.Completed, "<modelId>", content);
BinaryData responseData = operation.Value;

JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement;
Console.WriteLine(result.GetProperty("modelId").ToString());
Console.WriteLine(result.GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("createdDateTime").ToString());
Console.WriteLine(result.GetProperty("expirationDateTime").ToString());
Console.WriteLine(result.GetProperty("apiVersion").ToString());
Console.WriteLine(result.GetProperty("tags").GetProperty("<key>").ToString());
Console.WriteLine(result.GetProperty("buildMode").ToString());
Console.WriteLine(result.GetProperty("azureBlobSource").GetProperty("containerUrl").ToString());
Console.WriteLine(result.GetProperty("azureBlobSource").GetProperty("prefix").ToString());
Console.WriteLine(result.GetProperty("azureBlobFileListSource").GetProperty("containerUrl").ToString());
Console.WriteLine(result.GetProperty("azureBlobFileListSource").GetProperty("fileList").ToString());
Console.WriteLine(result.GetProperty("classifierId").ToString());
Console.WriteLine(result.GetProperty("split").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("buildMode").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("fieldSchema").GetProperty("<key>").GetProperty("type").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("fieldSchema").GetProperty("<key>").GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("fieldSchema").GetProperty("<key>").GetProperty("example").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("fieldSchema").GetProperty("<key>").GetProperty("items").GetProperty("type").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("fieldSchema").GetProperty("<key>").GetProperty("items").GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("fieldSchema").GetProperty("<key>").GetProperty("items").GetProperty("example").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("fieldSchema").GetProperty("<key>").GetProperty("properties").GetProperty("<key>").GetProperty("type").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("fieldSchema").GetProperty("<key>").GetProperty("properties").GetProperty("<key>").GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("fieldSchema").GetProperty("<key>").GetProperty("properties").GetProperty("<key>").GetProperty("example").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("fieldSchema").GetProperty("<key>").GetProperty("properties").GetProperty("<key>").GetProperty("items").GetProperty("type").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("fieldSchema").GetProperty("<key>").GetProperty("properties").GetProperty("<key>").GetProperty("items").GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("fieldSchema").GetProperty("<key>").GetProperty("properties").GetProperty("<key>").GetProperty("items").GetProperty("example").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("fieldConfidence").GetProperty("<key>").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("modelId").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("confidenceThreshold").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("features")[0].ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("queryFields")[0].ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("maxDocumentsToAnalyze").ToString());
Console.WriteLine(result.GetProperty("warnings")[0].GetProperty("code").ToString());
Console.WriteLine(result.GetProperty("warnings")[0].GetProperty("message").ToString());
Console.WriteLine(result.GetProperty("warnings")[0].GetProperty("target").ToString());
Console.WriteLine(result.GetProperty("trainingHours").ToString());

Applies to

CopyModelToAsync(WaitUntil, String, CopyAuthorization, CancellationToken)

Source:
DocumentIntelligenceAdministrationClient.cs

Copies document model to the target resource, region, and modelId.

public virtual System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.DocumentModelDetails>> CopyModelToAsync (Azure.WaitUntil waitUntil, string modelId, Azure.AI.DocumentIntelligence.CopyAuthorization copyToRequest, System.Threading.CancellationToken cancellationToken = default);
abstract member CopyModelToAsync : Azure.WaitUntil * string * Azure.AI.DocumentIntelligence.CopyAuthorization * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.DocumentModelDetails>>
override this.CopyModelToAsync : Azure.WaitUntil * string * Azure.AI.DocumentIntelligence.CopyAuthorization * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.DocumentModelDetails>>
Public Overridable Function CopyModelToAsync (waitUntil As WaitUntil, modelId As String, copyToRequest As CopyAuthorization, 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.

modelId
String

Unique document model name.

copyToRequest
CopyAuthorization

Copy to request parameters.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

modelId or copyToRequest is null.

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

Examples

This sample shows how to call CopyModelToAsync.

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

CopyAuthorization copyToRequest = new CopyAuthorization(
"<targetResourceId>",
"<targetResourceRegion>",
"<targetModelId>",
new Uri("http://localhost:3000"),
"<accessToken>",
DateTimeOffset.Parse("2022-05-10T18:57:31.2311892Z"));
Operation<DocumentModelDetails> operation = await client.CopyModelToAsync(WaitUntil.Completed, "<modelId>", copyToRequest);
DocumentModelDetails responseData = operation.Value;

This sample shows how to call CopyModelToAsync with all parameters.

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

CopyAuthorization copyToRequest = new CopyAuthorization(
"<targetResourceId>",
"<targetResourceRegion>",
"<targetModelId>",
new Uri("http://localhost:3000"),
"<accessToken>",
DateTimeOffset.Parse("2022-05-10T18:57:31.2311892Z"));
Operation<DocumentModelDetails> operation = await client.CopyModelToAsync(WaitUntil.Completed, "<modelId>", copyToRequest);
DocumentModelDetails responseData = operation.Value;

Applies to