DocumentIntelligenceAdministrationClient.BuildClassifierAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
BuildClassifierAsync(WaitUntil, RequestContent, RequestContext) |
[Protocol Method] Builds a custom document classifier.
|
BuildClassifierAsync(WaitUntil, BuildDocumentClassifierContent, CancellationToken) |
Builds a custom document classifier. |
BuildClassifierAsync(WaitUntil, RequestContent, RequestContext)
[Protocol Method] Builds a custom document classifier.
- This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
- Please try the simpler BuildClassifierAsync(WaitUntil, BuildDocumentClassifierContent, CancellationToken) convenience overload with strongly typed models first.
public virtual System.Threading.Tasks.Task<Azure.Operation<BinaryData>> BuildClassifierAsync (Azure.WaitUntil waitUntil, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member BuildClassifierAsync : Azure.WaitUntil * Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Operation<BinaryData>>
override this.BuildClassifierAsync : Azure.WaitUntil * Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Operation<BinaryData>>
Public Overridable Function BuildClassifierAsync (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 BuildClassifierAsync 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
{
classifierId = "<classifierId>",
docTypes = new
{
key = new object(),
},
});
Operation<BinaryData> operation = await client.BuildClassifierAsync(WaitUntil.Completed, content);
BinaryData responseData = operation.Value;
JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement;
Console.WriteLine(result.GetProperty("classifierId").ToString());
Console.WriteLine(result.GetProperty("createdDateTime").ToString());
Console.WriteLine(result.GetProperty("apiVersion").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").ToString());
This sample shows how to call BuildClassifierAsync 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
{
classifierId = "<classifierId>",
description = "<description>",
baseClassifierId = "<baseClassifierId>",
docTypes = new
{
key = new
{
sourceKind = "url",
azureBlobSource = new
{
containerUrl = "http://localhost:3000",
prefix = "<prefix>",
},
azureBlobFileListSource = new
{
containerUrl = "http://localhost:3000",
fileList = "<fileList>",
},
},
},
allowOverwrite = true,
});
Operation<BinaryData> operation = await client.BuildClassifierAsync(WaitUntil.Completed, content);
BinaryData responseData = operation.Value;
JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement;
Console.WriteLine(result.GetProperty("classifierId").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("baseClassifierId").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("sourceKind").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("azureBlobSource").GetProperty("containerUrl").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("azureBlobSource").GetProperty("prefix").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("azureBlobFileListSource").GetProperty("containerUrl").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("azureBlobFileListSource").GetProperty("fileList").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());
Applies to
BuildClassifierAsync(WaitUntil, BuildDocumentClassifierContent, CancellationToken)
Builds a custom document classifier.
public virtual System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.DocumentClassifierDetails>> BuildClassifierAsync (Azure.WaitUntil waitUntil, Azure.AI.DocumentIntelligence.BuildDocumentClassifierContent buildRequest, System.Threading.CancellationToken cancellationToken = default);
abstract member BuildClassifierAsync : Azure.WaitUntil * Azure.AI.DocumentIntelligence.BuildDocumentClassifierContent * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.DocumentClassifierDetails>>
override this.BuildClassifierAsync : Azure.WaitUntil * Azure.AI.DocumentIntelligence.BuildDocumentClassifierContent * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.DocumentClassifierDetails>>
Public Overridable Function BuildClassifierAsync (waitUntil As WaitUntil, buildRequest As BuildDocumentClassifierContent, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Operation(Of DocumentClassifierDetails))
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
- BuildDocumentClassifierContent
Build request parameters.
- cancellationToken
- CancellationToken
The cancellation token to use.
Returns
Exceptions
buildRequest
is null.
Examples
This sample shows how to call BuildClassifierAsync.
Uri endpoint = new Uri("<https://my-service.azure.com>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
DocumentIntelligenceAdministrationClient client = new DocumentIntelligenceAdministrationClient(endpoint, credential);
BuildDocumentClassifierContent buildRequest = new BuildDocumentClassifierContent("<classifierId>", new Dictionary<string, ClassifierDocumentTypeDetails>
{
["key"] = new ClassifierDocumentTypeDetails()
});
Operation<DocumentClassifierDetails> operation = await client.BuildClassifierAsync(WaitUntil.Completed, buildRequest);
DocumentClassifierDetails responseData = operation.Value;
This sample shows how to call BuildClassifierAsync with all parameters.
Uri endpoint = new Uri("<https://my-service.azure.com>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
DocumentIntelligenceAdministrationClient client = new DocumentIntelligenceAdministrationClient(endpoint, credential);
BuildDocumentClassifierContent buildRequest = new BuildDocumentClassifierContent("<classifierId>", new Dictionary<string, ClassifierDocumentTypeDetails>
{
["key"] = new ClassifierDocumentTypeDetails
{
SourceKind = ContentSourceKind.Url,
AzureBlobSource = new AzureBlobContentSource(new Uri("http://localhost:3000"))
{
Prefix = "<prefix>",
},
AzureBlobFileListSource = new AzureBlobFileListContentSource(new Uri("http://localhost:3000"), "<fileList>"),
}
})
{
Description = "<description>",
BaseClassifierId = "<baseClassifierId>",
AllowOverwrite = true,
};
Operation<DocumentClassifierDetails> operation = await client.BuildClassifierAsync(WaitUntil.Completed, buildRequest);
DocumentClassifierDetails responseData = operation.Value;
Applies to
Azure SDK for .NET