Class SearchKnowledgeBaseClientBuilder
- All Implemented Interfaces:
com.azure.core.client.traits.AzureKeyCredentialTrait<SearchKnowledgeBaseClientBuilder>, com.azure.core.client.traits.ConfigurationTrait<SearchKnowledgeBaseClientBuilder>, com.azure.core.client.traits.EndpointTrait<SearchKnowledgeBaseClientBuilder>, com.azure.core.client.traits.HttpTrait<SearchKnowledgeBaseClientBuilder>, com.azure.core.client.traits.TokenCredentialTrait<SearchKnowledgeBaseClientBuilder>
SearchKnowledgeBaseClient
and SearchKnowledgeBaseAsyncClient for interacting with Azure AI Search Knowledge Agents.
Overview
This builder enables the creation of both synchronous and asynchronous clients for Azure AI Search Knowledge Agents, allowing you to interact with knowledge retrieval and knowledgeBase-based search capabilities. The builder supports configuration of authentication, endpoint, knowledgeBase name, API version, and HTTP pipeline options, following Azure SDK for Java standards.
Getting Started
To create a client, configure the required properties such as the service endpoint, knowledgeBase name, API version, and authentication credentials. The builder supports both API key and Microsoft Entra ID (role-based) authentication. Additional options such as custom HTTP pipeline policies, retry options, logging, and serialization can also be configured.
Authentication
Azure AI Search Knowledge Agents support authentication using either an AzureKeyCredential (API key) or a
TokenCredential (Microsoft Entra ID). When using Microsoft Entra ID, you may also specify a SearchAudience
to target a specific Azure cloud environment.
Client Instantiation
Use buildClient() to create a synchronous SearchKnowledgeBaseClient, or buildAsyncClient() to create
an asynchronous SearchKnowledgeBaseAsyncClient. Each call to these methods returns a new client instance with the
configured options.
Thread Safety
Client instances created by this builder are thread-safe and intended to be shared and reused across threads. The builder itself is not thread-safe and should not be used concurrently from multiple threads.
Additional Information
- For more information about Azure AI Search Knowledge Agents, see the Azure documentation.
- For authentication details, see the Azure AI Search security documentation.
- For Azure SDK for Java guidelines, see the Azure SDK for Java Introduction.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddPolicy(com.azure.core.http.policy.HttpPipelinePolicy policy) audience(SearchAudience audience) Sets the audience for the Azure AI Search instance.Builds an asynchronousSearchKnowledgeBaseAsyncClient.Builds a synchronousSearchKnowledgeBaseClient.clientOptions(com.azure.core.util.ClientOptions clientOptions) configuration(com.azure.core.util.Configuration configuration) credential(com.azure.core.credential.AzureKeyCredential credential) credential(com.azure.core.credential.TokenCredential credential) Sets the service endpoint for the Azure AI Search instance.httpClient(com.azure.core.http.HttpClient client) httpLogOptions(com.azure.core.http.policy.HttpLogOptions logOptions) knowledgeBaseName(String knowledgeBaseName) Sets the knowledgeBase name for the Azure AI Search knowledgeBase.pipeline(com.azure.core.http.HttpPipeline httpPipeline) retryOptions(com.azure.core.http.policy.RetryOptions retryOptions) serviceVersion(SearchServiceVersion apiVersion) Sets the API version to use for requests.
-
Constructor Details
-
SearchKnowledgeBaseClientBuilder
public SearchKnowledgeBaseClientBuilder()Creates a new builder instance.
-
-
Method Details
-
endpoint
Sets the service endpoint for the Azure AI Search instance.- Specified by:
endpointin interfacecom.azure.core.client.traits.EndpointTrait<SearchKnowledgeBaseClientBuilder>- Parameters:
endpoint- The URL of the Azure AI Search instance.- Returns:
- The updated builder object.
-
knowledgeBaseName
Sets the knowledgeBase name for the Azure AI Search knowledgeBase.- Parameters:
knowledgeBaseName- The name of the knowledgeBase.- Returns:
- The updated builder object.
-
serviceVersion
Sets the API version to use for requests.- Parameters:
apiVersion- The API version.- Returns:
- The updated builder object.
-
credential
public SearchKnowledgeBaseClientBuilder credential(com.azure.core.credential.AzureKeyCredential credential) - Specified by:
credentialin interfacecom.azure.core.client.traits.AzureKeyCredentialTrait<SearchKnowledgeBaseClientBuilder>
-
credential
public SearchKnowledgeBaseClientBuilder credential(com.azure.core.credential.TokenCredential credential) - Specified by:
credentialin interfacecom.azure.core.client.traits.TokenCredentialTrait<SearchKnowledgeBaseClientBuilder>
-
audience
Sets the audience for the Azure AI Search instance.- Parameters:
audience- The audience to use.- Returns:
- The updated builder object.
-
httpLogOptions
public SearchKnowledgeBaseClientBuilder httpLogOptions(com.azure.core.http.policy.HttpLogOptions logOptions) - Specified by:
httpLogOptionsin interfacecom.azure.core.client.traits.HttpTrait<SearchKnowledgeBaseClientBuilder>
-
clientOptions
public SearchKnowledgeBaseClientBuilder clientOptions(com.azure.core.util.ClientOptions clientOptions) - Specified by:
clientOptionsin interfacecom.azure.core.client.traits.HttpTrait<SearchKnowledgeBaseClientBuilder>
-
addPolicy
public SearchKnowledgeBaseClientBuilder addPolicy(com.azure.core.http.policy.HttpPipelinePolicy policy) - Specified by:
addPolicyin interfacecom.azure.core.client.traits.HttpTrait<SearchKnowledgeBaseClientBuilder>
-
httpClient
- Specified by:
httpClientin interfacecom.azure.core.client.traits.HttpTrait<SearchKnowledgeBaseClientBuilder>
-
pipeline
- Specified by:
pipelinein interfacecom.azure.core.client.traits.HttpTrait<SearchKnowledgeBaseClientBuilder>
-
configuration
public SearchKnowledgeBaseClientBuilder configuration(com.azure.core.util.Configuration configuration) - Specified by:
configurationin interfacecom.azure.core.client.traits.ConfigurationTrait<SearchKnowledgeBaseClientBuilder>
-
retryOptions
public SearchKnowledgeBaseClientBuilder retryOptions(com.azure.core.http.policy.RetryOptions retryOptions) - Specified by:
retryOptionsin interfacecom.azure.core.client.traits.HttpTrait<SearchKnowledgeBaseClientBuilder>
-
buildClient
Builds a synchronousSearchKnowledgeBaseClient.- Returns:
- a new
SearchKnowledgeBaseClientinstance.
-
buildAsyncClient
Builds an asynchronousSearchKnowledgeBaseAsyncClient.- Returns:
- a new
SearchKnowledgeBaseAsyncClientinstance.
-