DocumentIntelligenceAdministrationClient.BuildClassifier 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
BuildClassifier(WaitUntil, BuildDocumentClassifierContent, CancellationToken) |
Builds a custom document classifier. |
BuildClassifier(WaitUntil, RequestContent, RequestContext) |
[Protocol Method] Builds a custom document classifier.
|
BuildClassifier(WaitUntil, BuildDocumentClassifierContent, CancellationToken)
Builds a custom document classifier.
public virtual Azure.Operation<Azure.AI.DocumentIntelligence.DocumentClassifierDetails> BuildClassifier (Azure.WaitUntil waitUntil, Azure.AI.DocumentIntelligence.BuildDocumentClassifierContent buildRequest, System.Threading.CancellationToken cancellationToken = default);
abstract member BuildClassifier : Azure.WaitUntil * Azure.AI.DocumentIntelligence.BuildDocumentClassifierContent * System.Threading.CancellationToken -> Azure.Operation<Azure.AI.DocumentIntelligence.DocumentClassifierDetails>
override this.BuildClassifier : Azure.WaitUntil * Azure.AI.DocumentIntelligence.BuildDocumentClassifierContent * System.Threading.CancellationToken -> Azure.Operation<Azure.AI.DocumentIntelligence.DocumentClassifierDetails>
Public Overridable Function BuildClassifier (waitUntil As WaitUntil, buildRequest As BuildDocumentClassifierContent, Optional cancellationToken As CancellationToken = Nothing) As 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 BuildClassifier.
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 = client.BuildClassifier(WaitUntil.Completed, buildRequest);
DocumentClassifierDetails responseData = operation.Value;
This sample shows how to call BuildClassifier 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 = client.BuildClassifier(WaitUntil.Completed, buildRequest);
DocumentClassifierDetails responseData = operation.Value;
Applies to
BuildClassifier(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 BuildClassifier(WaitUntil, BuildDocumentClassifierContent, CancellationToken) convenience overload with strongly typed models first.
public virtual Azure.Operation<BinaryData> BuildClassifier (Azure.WaitUntil waitUntil, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member BuildClassifier : Azure.WaitUntil * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Operation<BinaryData>
override this.BuildClassifier : Azure.WaitUntil * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Operation<BinaryData>
Public Overridable Function BuildClassifier (waitUntil As WaitUntil, content As RequestContent, Optional context As RequestContext = Nothing) As 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 BuildClassifier 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 = client.BuildClassifier(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 BuildClassifier 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 = client.BuildClassifier(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
Azure SDK for .NET