public final class ConfigurationClientBuilder extends Object
ConfigurationClients
and ConfigurationAsyncClients
, call buildClient
and buildAsyncClient
respectively to construct an instance of
the desired client.
The client needs the service endpoint of the Azure App Configuration store and access credential.
connectionString(String)
gives the builder the service endpoint and access
credential.
Instantiating an asynchronous Configuration Client
ConfigurationAsyncClient configurationAsyncClient = new ConfigurationClientBuilder() .connectionString(connectionString) .buildAsyncClient();
Instantiating a synchronous Configuration Client
ConfigurationClient configurationClient = new ConfigurationClientBuilder() .connectionString(connectionString) .buildClient();
Another way to construct the client is using a HttpPipeline
. The pipeline gives the client an
authenticated way to communicate with the service but it doesn't contain the service endpoint. 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 ConfigurationClient
and ConfigurationAsyncClient
is built.
HttpPipeline pipeline = new HttpPipelineBuilder() .policies(/* add policies */) .build(); ConfigurationClient configurationClient = new ConfigurationClientBuilder() .pipeline(pipeline) .endpoint("https://myconfig.azure.net/") .connectionString(connectionString) .buildClient();
ConfigurationAsyncClient
,
ConfigurationClient
Constructor and Description |
---|
ConfigurationClientBuilder()
Constructs a new builder used to configure and build
ConfigurationClients and ConfigurationAsyncClients . |
Modifier and Type | Method and Description |
---|---|
ConfigurationClientBuilder |
addPolicy(com.azure.core.http.policy.HttpPipelinePolicy policy)
Adds a policy to the set of existing policies.
|
ConfigurationAsyncClient |
buildAsyncClient()
Creates a
ConfigurationAsyncClient based on options set in the Builder. |
ConfigurationClient |
buildClient()
Creates a
ConfigurationClient based on options set in the Builder. |
ConfigurationClientBuilder |
clientOptions(com.azure.core.util.ClientOptions clientOptions)
Sets the
ClientOptions which enables various options to be set on the client. |
ConfigurationClientBuilder |
configuration(com.azure.core.util.Configuration configuration)
Sets the configuration store that is used during construction of the service client.
|
ConfigurationClientBuilder |
connectionString(String connectionString)
Sets the credential to use when authenticating HTTP requests.
|
ConfigurationClientBuilder |
credential(com.azure.core.credential.TokenCredential tokenCredential)
Sets the
TokenCredential used to authenticate HTTP requests. |
ConfigurationClientBuilder |
endpoint(String endpoint)
Sets the service endpoint for the Azure App Configuration instance.
|
ConfigurationClientBuilder |
httpClient(com.azure.core.http.HttpClient client)
Sets the HTTP client to use for sending and receiving requests to and from the service.
|
ConfigurationClientBuilder |
httpLogOptions(com.azure.core.http.policy.HttpLogOptions logOptions)
Sets the logging configuration for HTTP requests and responses.
|
ConfigurationClientBuilder |
pipeline(com.azure.core.http.HttpPipeline pipeline)
Sets the HTTP pipeline to use for the service client.
|
ConfigurationClientBuilder |
retryPolicy(com.azure.core.http.policy.HttpPipelinePolicy retryPolicy)
Sets the
HttpPipelinePolicy that is used to retry requests. |
ConfigurationClientBuilder |
serviceVersion(ConfigurationServiceVersion version)
Sets the
ConfigurationServiceVersion that is used when making API requests. |
public ConfigurationClientBuilder()
ConfigurationClients
and ConfigurationAsyncClients
.public ConfigurationClient buildClient()
ConfigurationClient
based on options set in the Builder. Every time buildClient()
is
called a new instance of ConfigurationClient
is created.
If pipeline
is set, then the pipeline
and endpoint
are used to create the client
. All other builder settings are ignored.
NullPointerException
- If endpoint
has not been set. This setting is automatically set when connectionString
is called. Or can be set explicitly by calling ConfigurationClientBuilder.endpoint(String)
.IllegalStateException
- If connectionString
has not been set.public ConfigurationAsyncClient buildAsyncClient()
ConfigurationAsyncClient
based on options set in the Builder. Every time buildAsyncClient()
is called a new instance of ConfigurationAsyncClient
is created.
If pipeline
is set, then the pipeline
and endpoint
are used to create the client
. All other builder settings are
ignored.
NullPointerException
- If endpoint
has not been set. This setting is automatically set when connectionString
is called. Or can be set explicitly by calling ConfigurationClientBuilder.endpoint(String)
.IllegalStateException
- If connectionString
has not been set.public ConfigurationClientBuilder endpoint(String endpoint)
endpoint
- The URL of the Azure App Configuration instance.IllegalArgumentException
- If endpoint
is null or it cannot be parsed into a valid URL.public ConfigurationClientBuilder clientOptions(com.azure.core.util.ClientOptions clientOptions)
ClientOptions
which enables various options to be set on the client. For example setting an
applicationId
using ClientOptions.setApplicationId(String)
to configure
the UserAgentPolicy
for telemetry/monitoring purposes.
More About Azure Core: Telemetry policy
clientOptions
- ClientOptions
.public ConfigurationClientBuilder connectionString(String connectionString)
endpoint
for this ConfigurationClientBuilder.connectionString
- Connection string in the format "endpoint={endpoint_value};id={id_value};
secret={secret_value}"NullPointerException
- If connectionString
is null.IllegalArgumentException
- If connectionString
is an empty string, the connectionString
secret is invalid, or the HMAC-SHA256 MAC algorithm cannot be instantiated.public ConfigurationClientBuilder credential(com.azure.core.credential.TokenCredential tokenCredential)
TokenCredential
used to authenticate HTTP requests.tokenCredential
- TokenCredential used to authenticate HTTP requests.NullPointerException
- If credential
is null.public ConfigurationClientBuilder httpLogOptions(com.azure.core.http.policy.HttpLogOptions logOptions)
If logLevel is not provided, default value of HttpLogDetailLevel.NONE
is set.
logOptions
- The logging configuration to use when sending and receiving HTTP requests/responses.public ConfigurationClientBuilder addPolicy(com.azure.core.http.policy.HttpPipelinePolicy policy)
policy
- The policy for service requests.NullPointerException
- If policy
is null.public ConfigurationClientBuilder httpClient(com.azure.core.http.HttpClient client)
client
- The HTTP client to use for requests.public ConfigurationClientBuilder pipeline(com.azure.core.http.HttpPipeline pipeline)
If pipeline
is set, all other settings are ignored, aside from endpoint
to build ConfigurationAsyncClient
or ConfigurationClient
.
pipeline
- The HTTP pipeline to use for sending service requests and receiving responses.public ConfigurationClientBuilder configuration(com.azure.core.util.Configuration configuration)
global
configuration store
, use Configuration.NONE
to bypass using configuration settings during construction.configuration
- The configuration store used topublic ConfigurationClientBuilder retryPolicy(com.azure.core.http.policy.HttpPipelinePolicy retryPolicy)
HttpPipelinePolicy
that is used to retry requests.
The default retry policy will be used if not provided ConfigurationClientBuilder.buildAsyncClient()
to
build ConfigurationAsyncClient
or ConfigurationClient
.
retryPolicy
- The HttpPipelinePolicy
that will be used to retry requests. For example,
RetryPolicy
can be used to retry requests.public ConfigurationClientBuilder serviceVersion(ConfigurationServiceVersion version)
ConfigurationServiceVersion
that is used when making API requests.
If a service version is not provided, the service version that will be used will be the latest known service version based on the version of the client library being used. If no service version is specified, updating to a newer version the client library will have the result of potentially moving to a newer service version.
version
- ConfigurationServiceVersion
of the service to be used when making requests.Copyright © 2021 Microsoft Corporation. All rights reserved.