Class AzureCliCredentialBuilder

All Implemented Interfaces:
com.azure.core.client.traits.HttpTrait<AzureCliCredentialBuilder>

public class AzureCliCredentialBuilder extends CredentialBuilderBase<AzureCliCredentialBuilder>
Fluent credential builder for instantiating a AzureCliCredential.

The Azure CLI is a command-line tool that allows users to manage Azure resources from their local machine or terminal. It allows users to authenticate interactively as a user and/or a service principal against Azure Active Directory (Azure AD) . The AzureCliCredential authenticates in a development environment and acquires a token on behalf of the logged-in user or service principal in Azure CLI. It acts as the Azure CLI logged in user or service principal and executes an Azure CLI command underneath to authenticate the application against Azure Active Directory.

Sample: Construct IntelliJCredential

The following code sample demonstrates the creation of a AzureCliCredential, using the AzureCliCredentialBuilder 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 azureCliCredential = new AzureCliCredentialBuilder()
     .build();
 
See Also:
  • Constructor Details

    • AzureCliCredentialBuilder

      public AzureCliCredentialBuilder()
  • Method Details

    • tenantId

      public AzureCliCredentialBuilder tenantId(String tenantId)
      Sets the tenant ID of the application.
      Parameters:
      tenantId - the tenant ID of the application.
      Returns:
      An updated instance of this builder with the tenant id set as specified.
    • processTimeout

      public AzureCliCredentialBuilder processTimeout(Duration processTimeout)
      Specifies a Duration timeout for calling the Azure CLI. The timeout period is applied on the Azure CLI command execution process invoked by the credential
      Parameters:
      processTimeout - The Duration to wait.
      Returns:
      An updated instance of this builder with the timeout specified.
    • build

      public AzureCliCredential build()
      Creates a new AzureCliCredential with the current configurations.
      Returns:
      a AzureCliCredential with the current configurations.
    • additionallyAllowedTenants

      public AzureCliCredentialBuilder additionallyAllowedTenants(String... additionallyAllowedTenants)
      Specifies tenants in addition to the specified tenantId for which the credential may acquire tokens. Add the wildcard value "*" to allow the credential to acquire tokens for any tenant the logged in account can access. If no value is specified for tenantId this option will have no effect, and the credential will acquire tokens for any requested tenant.
      Parameters:
      additionallyAllowedTenants - the additionally allowed tenants.
      Returns:
      An updated instance of this builder with the additional tenants configured.
    • additionallyAllowedTenants

      public AzureCliCredentialBuilder additionallyAllowedTenants(List<String> additionallyAllowedTenants)
      Specifies tenants in addition to the specified tenantId for which the credential may acquire tokens. Add the wildcard value "*" to allow the credential to acquire tokens for any tenant the logged in account can access. If no value is specified for tenantId this option will have no effect, and the credential will acquire tokens for any requested tenant.
      Parameters:
      additionallyAllowedTenants - the additionally allowed tenants.
      Returns:
      An updated instance of this builder with the additional tenants configured.