Class TextAnalyticsClientBuilder

java.lang.Object
com.azure.ai.textanalytics.TextAnalyticsClientBuilder
All Implemented Interfaces:
AzureKeyCredentialTrait<TextAnalyticsClientBuilder>, ConfigurationTrait<TextAnalyticsClientBuilder>, EndpointTrait<TextAnalyticsClientBuilder>, HttpTrait<TextAnalyticsClientBuilder>, TokenCredentialTrait<TextAnalyticsClientBuilder>

This class provides a fluent builder API to help instantiation of TextAnalyticsClients and TextAnalyticsAsyncClients, call buildClient() buildClient} and buildAsyncClient respectively to construct an instance of the desired client.

The client needs the service endpoint of the Azure Text Analytics to access the resource service. credential(AzureKeyCredential) or credential(TokenCredential) give the builder access credential.

Instantiating an asynchronous Text Analytics Client

 TextAnalyticsAsyncClient textAnalyticsAsyncClient = new TextAnalyticsClientBuilder()
     .credential(new AzureKeyCredential("{key}"))
     .endpoint("{endpoint}")
     .buildAsyncClient();
 

Instantiating a synchronous Text Analytics Client

 TextAnalyticsClient textAnalyticsClient = new TextAnalyticsClientBuilder()
     .credential(new AzureKeyCredential("{key}"))
     .endpoint("{endpoint}")
     .buildClient();
 

Another way to construct the client is using a HttpPipeline. The pipeline gives the client an authenticated way to communicate with the service. Set the pipeline with this and set the service endpoint with this. Using a pipeline requires additional setup but allows for finer control on how the TextAnalyticsClient and TextAnalyticsAsyncClient is built.

 HttpPipeline pipeline = new HttpPipelineBuilder()
     .policies(/* add policies */)
     .build();

 TextAnalyticsClient textAnalyticsClient = new TextAnalyticsClientBuilder()
     .credential(new AzureKeyCredential("{key}"))
     .endpoint("{endpoint}")
     .pipeline(pipeline)
     .buildClient();
 
See Also: