Class TableServiceClientBuilder
- All Implemented Interfaces:
AzureNamedKeyCredentialTrait<TableServiceClientBuilder>
,AzureSasCredentialTrait<TableServiceClientBuilder>
,ConfigurationTrait<TableServiceClientBuilder>
,ConnectionStringTrait<TableServiceClientBuilder>
,EndpointTrait<TableServiceClientBuilder>
,HttpTrait<TableServiceClientBuilder>
,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
ConstructorDescriptionCreates a builder instance that is able to configure and constructTableServiceClient
andTableServiceAsyncClient
objects. -
Method Summary
Modifier and TypeMethodDescriptionaddPolicy
(HttpPipelinePolicy pipelinePolicy) Adds apipeline policy
to apply on each request sent.Creates aTableServiceAsyncClient
based on options set in the builder.Creates aTableServiceClient
based on options set in the builder.clientOptions
(ClientOptions clientOptions) Allows for setting common properties such as application ID, headers, proxy configuration, etc.configuration
(Configuration configuration) Sets theconfiguration
object used to retrieve environment configuration values during building of the client.connectionString
(String connectionString) Sets the connection string to connect to the service.credential
(AzureNamedKeyCredential credential) Sets theAzureNamedKeyCredential
used to authorize requests sent to the service.credential
(AzureSasCredential credential) Sets theAzureSasCredential
used to authorize requests sent to the service.credential
(TokenCredential credential) Sets theTokenCredential
used to authorize requests sent to the service.Enable tenant discovery when authenticating with the Table Service.Sets the service endpoint.httpClient
(HttpClient httpClient) Sets theHttpClient
to use for sending and receiving requests to and from the service.httpLogOptions
(HttpLogOptions logOptions) Sets thelogging configuration
to use when sending and receiving requests to and from the service.pipeline
(HttpPipeline pipeline) Sets theHttpPipeline
to use for the service client.retryOptions
(RetryOptions retryOptions) Sets theRetryOptions
for all the requests made through the client.retryPolicy
(RetryPolicy retryPolicy) Sets the requestRetryPolicy
for all the requests made through the client.Sets the SAS token used to authorize requests sent to the service.serviceVersion
(TableServiceVersion serviceVersion) Sets theservice version
that is used when making API requests.
-
Constructor Details
-
TableServiceClientBuilder
public TableServiceClientBuilder()Creates a builder instance that is able to configure and constructTableServiceClient
andTableServiceAsyncClient
objects.
-
-
Method Details
-
buildClient
Creates aTableServiceClient
based on options set in the builder.- Returns:
- A
TableServiceClient
created from the configurations in this builder. - Throws:
NullPointerException
- Ifendpoint
isnull
.IllegalArgumentException
- Ifendpoint
is malformed or empty.IllegalStateException
- If no form of authentication orendpoint
have been specified or if multiple forms of authentication are provided, with the exception ofsasToken
+connectionString
. Also thrown ifendpoint
and/orsasToken
are set alongside aconnectionString
and the endpoint and/or SAS token in the latter are different than the former, respectively.
-
buildAsyncClient
Creates aTableServiceAsyncClient
based on options set in the builder.- Returns:
- A
TableServiceAsyncClient
created from the configurations in this builder. - Throws:
NullPointerException
- Ifendpoint
isnull
.IllegalArgumentException
- Ifendpoint
is malformed or empty.IllegalStateException
- If no form of authentication orendpoint
have been specified or if multiple forms of authentication are provided, with the exception ofsasToken
+connectionString
. Also thrown ifendpoint
and/orsasToken
are set alongside aconnectionString
and 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:
connectionString
in interfaceConnectionStringTrait<TableServiceClientBuilder>
- Parameters:
connectionString
- Connection string of the storage or CosmosDB table API account.- Returns:
- The updated
TableServiceClientBuilder
. - Throws:
NullPointerException
- IfconnectionString
isnull
.IllegalArgumentException
- IfconnectionString
isn't a valid connection string.
-
endpoint
Sets the service endpoint.- Specified by:
endpoint
in interfaceEndpointTrait<TableServiceClientBuilder>
- Parameters:
endpoint
- The URL of the storage or CosmosDB table API account endpoint.- Returns:
- The updated
TableServiceClientBuilder
. - Throws:
IllegalArgumentException
- Ifendpoint
isn't a valid URL.
-
pipeline
Sets theHttpPipeline
to use for the service client.Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a
HttpPipeline
is specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipeline
is 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 anHttpPipeline
is specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.The
endpoint
is not ignored whenpipeline
is set.- Specified by:
pipeline
in interfaceHttpTrait<TableServiceClientBuilder>
- Parameters:
pipeline
-HttpPipeline
to use for sending service requests and receiving responses.- Returns:
- The updated
TableServiceClientBuilder
.
-
configuration
Sets theconfiguration
object used to retrieve environment configuration values during building of the client.The
default configuration store
is a clone of theglobal configuration store
, useConfiguration.NONE
to bypass using configuration settings during construction.- Specified by:
configuration
in interfaceConfigurationTrait<TableServiceClientBuilder>
- Parameters:
configuration
-Configuration
store 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
- IfsasToken
isnull
.IllegalArgumentException
- IfsasToken
is empty.
-
credential
Sets theAzureSasCredential
used to authorize requests sent to the service. Setting this is mutually exclusive withcredential(AzureNamedKeyCredential)
,credential(TokenCredential)
orsasToken(String)
.- Specified by:
credential
in interfaceAzureSasCredentialTrait<TableServiceClientBuilder>
- Parameters:
credential
-AzureSasCredential
used to authorize requests sent to the service.- Returns:
- The updated
TableServiceClientBuilder
. - Throws:
NullPointerException
- Ifcredential
isnull
.
-
credential
Sets theAzureNamedKeyCredential
used to authorize requests sent to the service. Setting this is mutually exclusive with usingcredential(AzureSasCredential)
,credential(TokenCredential)
orsasToken(String)
.- Specified by:
credential
in interfaceAzureNamedKeyCredentialTrait<TableServiceClientBuilder>
- Parameters:
credential
-AzureNamedKeyCredential
used to authorize requests sent to the service.- Returns:
- The updated
TableServiceClientBuilder
. - Throws:
NullPointerException
- Ifcredential
isnull
.
-
credential
Sets theTokenCredential
used 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 theTokenCredential
type. Setting this is mutually exclusive with usingcredential(AzureNamedKeyCredential)
,credential(AzureSasCredential)
orsasToken(String)
.- Specified by:
credential
in interfaceTokenCredentialTrait<TableServiceClientBuilder>
- Parameters:
credential
-TokenCredential
used to authorize requests sent to the service.- Returns:
- The updated
TableServiceClientBuilder
. - Throws:
NullPointerException
- Ifcredential
isnull
.
-
httpClient
Sets theHttpClient
to 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
HttpPipeline
is specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipeline
is 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 anHttpPipeline
is 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:
httpClient
in interfaceHttpTrait<TableServiceClientBuilder>
- Parameters:
httpClient
- TheHttpClient
to use for requests.- Returns:
- The updated
TableServiceClientBuilder
.
-
httpLogOptions
Sets thelogging configuration
to use when sending and receiving requests to and from the service. If alogLevel
is not provided, default value ofHttpLogDetailLevel.NONE
is set.Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a
HttpPipeline
is specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipeline
is 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 anHttpPipeline
is 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:
httpLogOptions
in interfaceHttpTrait<TableServiceClientBuilder>
- Parameters:
logOptions
- Thelogging configuration
to use when sending and receiving requests to and from the service.- Returns:
- The updated
TableServiceClientBuilder
.
-
addPolicy
Adds apipeline policy
to apply on each request sent.Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a
HttpPipeline
is specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipeline
is 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 anHttpPipeline
is 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:
addPolicy
in interfaceHttpTrait<TableServiceClientBuilder>
- Parameters:
pipelinePolicy
- Apipeline policy
.- Returns:
- The updated
TableServiceClientBuilder
. - Throws:
NullPointerException
- IfpipelinePolicy
isnull
.
-
serviceVersion
Sets theservice version
that is used when making API requests.If a
service version
is not provided, theservice version
that will be used will be the latest knownservice version
based on the version of the client library being used. If noservice version
is 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 version
may also mean that the service will return an error for newer APIs.- Parameters:
serviceVersion
- TheTableServiceVersion
of the service to be used when making requests.- Returns:
- The updated
TableServiceClientBuilder
.
-
retryPolicy
Sets the requestRetryPolicy
for all the requests made through the client. The defaultRetryPolicy
will 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 theRetryOptions
for all the requests made through the client.Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a
HttpPipeline
is specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipeline
is 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 anHttpPipeline
is 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:
retryOptions
in interfaceHttpTrait<TableServiceClientBuilder>
- Parameters:
retryOptions
- TheRetryOptions
to use for all the requests made through the client.- Returns:
- The updated
TableServiceClientBuilder
object.
-
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 theHttpClientOptions
class (a subclass of theClientOptions
base 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
HttpPipeline
is specified, this takes precedence over all other APIs in the trait, and they will be ignored. If noHttpPipeline
is 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 anHttpPipeline
is 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:
clientOptions
in interfaceHttpTrait<TableServiceClientBuilder>
- Parameters:
clientOptions
- A configured instance ofHttpClientOptions
.- Returns:
- The updated
TableServiceClientBuilder
. - See Also:
-
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
401
response containing an authentication challenge, which will be subsequently used to retrieve an access token to authorize all further requests with.- Returns:
- The updated
TableServiceClientBuilder
.
-