SecretClientBuilder (Azure SDK for Java Reference Documentation)
Michael Gray
Published Feb 16, 2026
This class provides a fluent builder API to help aid the configuration and instantiation of the
secret async client and secret client, by calling buildAsyncClient and buildClient respectively. It constructs an instance of the desired client. The minimal configuration options required by secretClientBuilder to build SecretAsyncClient are vaultUrl and credential.
SecretAsyncClient secretAsyncClient = new SecretClientBuilder() .credential(new DefaultAzureCredentialBuilder().build()) .vaultUrl("") .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS)) .buildAsyncClient(); Samples to construct the sync client
SecretClient secretClient = new SecretClientBuilder() .credential(new DefaultAzureCredentialBuilder().build()) .vaultUrl("") .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS)) .buildClient(); The log detail level, multiple custom policies and custom http client can be optionally configured in the SecretClientBuilder.
SecretAsyncClient secretAsyncClient = new SecretClientBuilder() .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS)) .vaultUrl("") .credential(new DefaultAzureCredentialBuilder().build()) .httpClient(HttpClient.createDefault()) .buildAsyncClient(); Alternatively, custom http pipeline with custom HttpPipelinePolicy policies and vaultUrl can be specified. It provides finer control over the construction of client
HttpPipeline pipeline = new HttpPipelineBuilder() .policies(new KeyVaultCredentialPolicy(credential), new RetryPolicy()) .build(); SecretAsyncClient secretAsyncClient = new SecretClientBuilder() .pipeline(pipeline) .vaultUrl("") .buildAsyncClient();