Class EnvironmentCredentialBuilder
- All Implemented Interfaces:
com.azure.core.client.traits.HttpTrait<EnvironmentCredentialBuilder>
EnvironmentCredential
.
The EnvironmentCredential
is appropriate for scenarios where the application is looking to read credential
information from environment variables. The credential supports service principal and user credential based
authentication and requires a set of environment variables to be configured for each scenario.
Sample: Construct EnvironmentCredential
The following code sample demonstrates the creation of a EnvironmentCredential
,
using the EnvironmentCredentialBuilder
to configure it. Once this credential is
created, it may be passed into the builder of many of the Azure SDK for Java client builders as the 'credential'
parameter.
TokenCredential environmentCredential = new EnvironmentCredentialBuilder() .build();
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionauthorityHost
(String authorityHost) Specifies the Azure Active Directory endpoint to acquire tokens.build()
Creates a newEnvironmentCredential
with the current configurations.executorService
(ExecutorService executorService) Specifies the ExecutorService to be used to execute the authentication requests.Methods inherited from class com.azure.identity.CredentialBuilderBase
addPolicy, clientOptions, configuration, enableAccountIdentifierLogging, httpClient, httpLogOptions, httpPipeline, maxRetry, pipeline, proxyOptions, retryOptions, retryPolicy, retryTimeout
-
Constructor Details
-
EnvironmentCredentialBuilder
public EnvironmentCredentialBuilder()
-
-
Method Details
-
authorityHost
Specifies the Azure Active Directory endpoint to acquire tokens.- Parameters:
authorityHost
- the Azure Active Directory endpoint- Returns:
- An updated instance of this builder with the authority host set as specified.
-
executorService
Specifies the ExecutorService to be used to execute the authentication requests. Developer is responsible for maintaining the lifecycle of the ExecutorService.If this is not configured, the
ForkJoinPool.commonPool()
will be used which is also shared with other application tasks. If the common pool is heavily used for other tasks, authentication requests might starve and setting up this executor service should be considered.The executor service and can be safely shutdown if the TokenCredential is no longer being used by the Azure SDK clients and should be shutdown before the application exits.
- Parameters:
executorService
- the executor service to use for executing authentication requests.- Returns:
- An updated instance of this builder with the executor service set as specified.
-
build
Creates a newEnvironmentCredential
with the current configurations.- Returns:
- a
EnvironmentCredential
with the current configurations.
-