Class TableServiceClientBuilder
- All Implemented Interfaces:
com.azure.core.client.traits.AzureNamedKeyCredentialTrait<TableServiceClientBuilder>,com.azure.core.client.traits.AzureSasCredentialTrait<TableServiceClientBuilder>,com.azure.core.client.traits.ConfigurationTrait<TableServiceClientBuilder>,com.azure.core.client.traits.ConnectionStringTrait<TableServiceClientBuilder>,com.azure.core.client.traits.EndpointTrait<TableServiceClientBuilder>,com.azure.core.client.traits.HttpTrait<TableServiceClientBuilder>,com.azure.core.client.traits.TokenCredentialTrait<TableServiceClientBuilder>
TableServiceClient and TableServiceAsyncClient objects. Call buildClient() or
buildAsyncClient(), respectively, to construct an instance of the desired client.
The minimal configuration options required by TableServiceClientBuilder to build a
TableServiceClient or TableServiceAsyncClient are an endpoint and a form of
authentication, which can be set via: connectionString(String),
credential(AzureSasCredential),
credential(AzureNamedKeyCredential) or
sasToken(String)
Samples to construct a sync client
TableServiceClient tableServiceClient = new TableServiceClientBuilder()
.endpoint("https://myvault.azure.net/")
.credential(new AzureNamedKeyCredential("name", "key"))
.buildClient();
Samples to construct an async client
TableServiceAsyncClient tableServiceAsyncClient = new TableServiceClientBuilder()
.endpoint("https://myvault.azure.net/")
.credential(new AzureNamedKeyCredential("name", "key"))
.buildAsyncClient();
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a builder instance that is able to configure and constructTableServiceClientandTableServiceAsyncClientobjects. -
Method Summary
Modifier and TypeMethodDescriptionaddPolicy(com.azure.core.http.policy.HttpPipelinePolicy pipelinePolicy) Adds apipeline policyto apply on each request sent.Creates aTableServiceAsyncClientbased on options set in the builder.Creates aTableServiceClientbased on options set in the builder.clientOptions(com.azure.core.util.ClientOptions clientOptions) Allows for setting common properties such as application ID, headers, proxy configuration, etc.configuration(com.azure.core.util.Configuration configuration) Sets theconfigurationobject used to retrieve environment configuration values during building of the client.connectionString(String connectionString) Sets the connection string to connect to the service.credential(com.azure.core.credential.AzureNamedKeyCredential credential) Sets theAzureNamedKeyCredentialused to authorize requests sent to the service.credential(com.azure.core.credential.AzureSasCredential credential) Sets theAzureSasCredentialused to authorize requests sent to the service.credential(com.azure.core.credential.TokenCredential credential) Sets theTokenCredentialused to authorize requests sent to the service.Enable tenant discovery when authenticating with the Table Service.Sets the service endpoint.httpClient(com.azure.core.http.HttpClient httpClient) Sets theHttpClientto use for sending and receiving requests to and from the service.httpLogOptions(com.azure.core.http.policy.HttpLogOptions logOptions) Sets thelogging configurationto use when sending and receiving requests to and from the service.pipeline(com.azure.core.http.HttpPipeline pipeline) Sets theHttpPipelineto use for the service client.retryOptions(com.azure.core.http.policy.RetryOptions retryOptions) Sets theRetryOptionsfor all the requests made through the client.retryPolicy(com.azure.core.http.policy.RetryPolicy retryPolicy) Sets the requestRetryPolicyfor all the requests made through the client.Sets the SAS token used to authorize requests sent to the service.serviceVersion(TableServiceVersion serviceVersion) Sets theservice versionthat is used when making API requests.
-
Constructor Details
-
TableServiceClientBuilder
public TableServiceClientBuilder()Creates a builder instance that is able to configure and constructTableServiceClientandTableServiceAsyncClientobjects.
-
-
Method Details
-
buildClient
Creates aTableServiceClientbased on options set in the builder.- Returns:
- A
TableServiceClientcreated from the configurations in this builder. - Throws:
NullPointerException- Ifendpointisnull.IllegalArgumentException- Ifendpointis malformed or empty.IllegalStateException- If no form of authentication orendpointhave been specified or if multiple forms of authentication are provided, with the exception ofsasToken+connectionString. Also thrown ifendpointand/orsasTokenare set alongside aconnectionStringand the endpoint and/or SAS token in the latter are different than the former, respectively.
-
buildAsyncClient
Creates aTableServiceAsyncClientbased on options set in the builder.- Returns:
- A
TableServiceAsyncClientcreated from the configurations in this builder. - Throws:
NullPointerException- Ifendpointisnull.IllegalArgumentException- Ifendpointis malformed or empty.IllegalStateException- If no form of authentication orendpointhave been specified or if multiple forms of authentication are provided, with the exception ofsasToken+connectionString. Also thrown ifendpointand/orsasTokenare set alongside aconnectionStringand the endpoint and/or SAS token in the latter are different than the former, respectively.
-
connectionString
Sets the connection string to connect to the service.- Specified by:
connectionStringin interfacecom.azure.core.client.traits.ConnectionStringTrait<TableServiceClientBuilder>- Parameters:
connectionString- Connection string of the storage or CosmosDB table API account.- Returns:
- The updated
TableServiceClientBuilder. - Throws:
NullPointerException- IfconnectionStringisnull.IllegalArgumentException- IfconnectionStringisn't a valid connection string.
-
endpoint
Sets the service endpoint.- Specified by:
endpointin interfacecom.azure.core.client.traits.EndpointTrait<TableServiceClientBuilder>- Parameters:
endpoint- The URL of the storage or CosmosDB table API account endpoint.- Returns:
- The updated
TableServiceClientBuilder. - Throws:
IllegalArgumentException- Ifendpointisn't a valid URL.
-
pipeline
Sets theHttpPipelineto use for the service client.Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a
HttpPipelineis specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipelineis specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if anHttpPipelineis specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.The
endpointis not ignored whenpipelineis set.- Specified by:
pipelinein interfacecom.azure.core.client.traits.HttpTrait<TableServiceClientBuilder>- Parameters:
pipeline-HttpPipelineto use for sending service requests and receiving responses.- Returns:
- The updated
TableServiceClientBuilder.
-
configuration
Sets theconfigurationobject used to retrieve environment configuration values during building of the client.The
default configuration storeis a clone of theglobal configuration store, useConfiguration.NONEto bypass using configuration settings during construction.- Specified by:
configurationin interfacecom.azure.core.client.traits.ConfigurationTrait<TableServiceClientBuilder>- Parameters:
configuration-Configurationstore used to retrieve environment configuration.- Returns:
- The updated
TableServiceClientBuilder.
-
sasToken
Sets the SAS token used to authorize requests sent to the service. Setting this is mutually exclusive withcredential(AzureNamedKeyCredential),credential(AzureSasCredential)orcredential(TokenCredential).- Parameters:
sasToken- The SAS token to use for authenticating requests.- Returns:
- The updated
TableServiceClientBuilder. - Throws:
NullPointerException- IfsasTokenisnull.IllegalArgumentException- IfsasTokenis empty.
-
credential
public TableServiceClientBuilder credential(com.azure.core.credential.AzureSasCredential credential) Sets theAzureSasCredentialused to authorize requests sent to the service. Setting this is mutually exclusive withcredential(AzureNamedKeyCredential),credential(TokenCredential)orsasToken(String).- Specified by:
credentialin interfacecom.azure.core.client.traits.AzureSasCredentialTrait<TableServiceClientBuilder>- Parameters:
credential-AzureSasCredentialused to authorize requests sent to the service.- Returns:
- The updated
TableServiceClientBuilder. - Throws:
NullPointerException- Ifcredentialisnull.
-
credential
public TableServiceClientBuilder credential(com.azure.core.credential.AzureNamedKeyCredential credential) Sets theAzureNamedKeyCredentialused to authorize requests sent to the service. Setting this is mutually exclusive with usingcredential(AzureSasCredential),credential(TokenCredential)orsasToken(String).- Specified by:
credentialin interfacecom.azure.core.client.traits.AzureNamedKeyCredentialTrait<TableServiceClientBuilder>- Parameters:
credential-AzureNamedKeyCredentialused to authorize requests sent to the service.- Returns:
- The updated
TableServiceClientBuilder. - Throws:
NullPointerException- Ifcredentialisnull.
-
credential
Sets theTokenCredentialused to authorize requests sent to the service. Refer to the Azure SDK for Java identity and authentication documentation for more details on proper usage of theTokenCredentialtype. Setting this is mutually exclusive with usingcredential(AzureNamedKeyCredential),credential(AzureSasCredential)orsasToken(String).- Specified by:
credentialin interfacecom.azure.core.client.traits.TokenCredentialTrait<TableServiceClientBuilder>- Parameters:
credential-TokenCredentialused to authorize requests sent to the service.- Returns:
- The updated
TableServiceClientBuilder. - Throws:
NullPointerException- Ifcredentialisnull.
-
httpClient
Sets theHttpClientto use for sending and receiving requests to and from the service.Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a
HttpPipelineis specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipelineis specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if anHttpPipelineis specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.- Specified by:
httpClientin interfacecom.azure.core.client.traits.HttpTrait<TableServiceClientBuilder>- Parameters:
httpClient- TheHttpClientto use for requests.- Returns:
- The updated
TableServiceClientBuilder.
-
httpLogOptions
public TableServiceClientBuilder httpLogOptions(com.azure.core.http.policy.HttpLogOptions logOptions) Sets thelogging configurationto use when sending and receiving requests to and from the service. If alogLevelis not provided, default value ofHttpLogDetailLevel.NONEis set.Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a
HttpPipelineis specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipelineis specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if anHttpPipelineis specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.- Specified by:
httpLogOptionsin interfacecom.azure.core.client.traits.HttpTrait<TableServiceClientBuilder>- Parameters:
logOptions- Thelogging configurationto use when sending and receiving requests to and from the service.- Returns:
- The updated
TableServiceClientBuilder.
-
addPolicy
public TableServiceClientBuilder addPolicy(com.azure.core.http.policy.HttpPipelinePolicy pipelinePolicy) Adds apipeline policyto apply on each request sent.Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a
HttpPipelineis specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipelineis specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if anHttpPipelineis specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.- Specified by:
addPolicyin interfacecom.azure.core.client.traits.HttpTrait<TableServiceClientBuilder>- Parameters:
pipelinePolicy- Apipeline policy.- Returns:
- The updated
TableServiceClientBuilder. - Throws:
NullPointerException- IfpipelinePolicyisnull.
-
serviceVersion
Sets theservice versionthat is used when making API requests.If a
service versionis not provided, theservice versionthat will be used will be the latest knownservice versionbased on the version of the client library being used. If noservice versionis specified, updating to a newer version of the client library will have the result of potentially moving to a newerservice version.Targeting a specific
service versionmay also mean that the service will return an error for newer APIs.- Parameters:
serviceVersion- TheTableServiceVersionof the service to be used when making requests.- Returns:
- The updated
TableServiceClientBuilder.
-
retryPolicy
Sets the requestRetryPolicyfor all the requests made through the client. The defaultRetryPolicywill be used in the pipeline, if not provided. Setting this is mutually exclusive with usingretryOptions(RetryOptions).- Parameters:
retryPolicy-RetryPolicy.- Returns:
- The updated
TableServiceClientBuilder.
-
retryOptions
Sets theRetryOptionsfor all the requests made through the client.Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a
HttpPipelineis specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipelineis specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if anHttpPipelineis specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.Setting this is mutually exclusive with using
retryPolicy(RetryPolicy).- Specified by:
retryOptionsin interfacecom.azure.core.client.traits.HttpTrait<TableServiceClientBuilder>- Parameters:
retryOptions- TheRetryOptionsto use for all the requests made through the client.- Returns:
- The updated
TableServiceClientBuilderobject.
-
clientOptions
Allows for setting common properties such as application ID, headers, proxy configuration, etc. Note that it is recommended that this method be called with an instance of theHttpClientOptionsclass (a subclass of theClientOptionsbase class). The HttpClientOptions subclass provides more configuration options suitable for HTTP clients, which is applicable for any class that implements this HttpTrait interface.Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a
HttpPipelineis specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipelineis specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if anHttpPipelineis specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.- Specified by:
clientOptionsin interfacecom.azure.core.client.traits.HttpTrait<TableServiceClientBuilder>- Parameters:
clientOptions- A configured instance ofHttpClientOptions.- Returns:
- The updated
TableServiceClientBuilder. - See Also:
-
HttpClientOptions
-
enableTenantDiscovery
Enable tenant discovery when authenticating with the Table Service. This functionality is disabled by default and only available for Storage endpoints using service version2020_12_06.Enable this if there is a chance for your application and the Storage account it communicates with to reside in different tenants. If this is enabled, clients created using this builder will make an unauthorized initial service request that will be met with a
401response containing an authentication challenge, which will be subsequently used to retrieve an access token to authorize all further requests with.- Returns:
- The updated
TableServiceClientBuilder.
-