AzureDeveloperCliCredentialBuilder Class

public class AzureDeveloperCliCredentialBuilder
extends CredentialBuilderBase<AzureDeveloperCliCredentialBuilder>

Fluent credential builder for instantiating a AzureDeveloperCliCredential.

Azure Developer CLI is a command-line interface tool that allows developers to create, manage, and deploy resources in Azure. It's built on top of the Azure CLI and provides additional functionality specific to Azure developers. It allows users to authenticate as a user and/or a service principal against Microsoft Entra ID. The AzureDeveloperCliCredential authenticates in a development environment and acquires a token on behalf of the logged-in user or service principal in Azure Developer CLI. It acts as the Azure Developer CLI logged in user or service principal and executes an Azure CLI command underneath to authenticate the application against Microsoft Entra ID.

Sample: Construct AzureDeveloperCliCredential

The following code sample demonstrates the creation of a AzureDeveloperCliCredential, using the AzureDeveloperCliCredentialBuilder 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 azureDevCliCredential = new AzureDeveloperCliCredentialBuilder()
     .build();

Constructor Summary

Constructor Description
AzureDeveloperCliCredentialBuilder()

Constructs an instance of AzureDeveloperCliCredentialBuilder.

Method Summary

Modifier and Type Method and Description
AzureDeveloperCliCredentialBuilder additionallyAllowedTenants(String[] additionallyAllowedTenants)

Specifies tenants in addition to the specified tenantId for which the credential may acquire tokens.

AzureDeveloperCliCredentialBuilder additionallyAllowedTenants(List<String> additionallyAllowedTenants)

Specifies tenants in addition to the specified tenantId for which the credential may acquire tokens.

AzureDeveloperCliCredential build()

Creates a new AzureDeveloperCliCredential with the current configurations.

AzureDeveloperCliCredentialBuilder processTimeout(Duration processTimeout)

Specifies a Duration timeout for calling the Azure Developer CLI.

AzureDeveloperCliCredentialBuilder tenantId(String tenantId)

Sets the tenant ID of the application.

Methods inherited from CredentialBuilderBase

Methods inherited from java.lang.Object

Constructor Details

AzureDeveloperCliCredentialBuilder

public AzureDeveloperCliCredentialBuilder()

Constructs an instance of AzureDeveloperCliCredentialBuilder.

Method Details

additionallyAllowedTenants

public AzureDeveloperCliCredentialBuilder 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 AzureDeveloperCliCredentialBuilder additionallyAllowedTenants(List 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.

build

public AzureDeveloperCliCredential build()

Creates a new AzureDeveloperCliCredential with the current configurations.

Returns:

a AzureDeveloperCliCredential with the current configurations.

processTimeout

public AzureDeveloperCliCredentialBuilder processTimeout(Duration processTimeout)

Specifies a Duration timeout for calling the Azure Developer CLI. The timeout period is applied on the Azure Developer 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.

tenantId

public AzureDeveloperCliCredentialBuilder 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.

Applies to