AzurePowerShellCredentialBuilder Class
- java.
lang. Object - com.
azure. identity. CredentialBuilderBase<T> - com.
azure. identity. AzurePowerShellCredentialBuilder
- com.
- com.
public class AzurePowerShellCredentialBuilder
extends CredentialBuilderBase<AzurePowerShellCredentialBuilder>
Fluent credential builder for instantiating a AzurePowerShellCredential.
The Azure Powershell 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 Microsoft Entra ID. The AzurePowerShellCredential authenticates in a development environment and acquires a token on behalf of the logged-in user or service principal in Azure Powershell. It acts as the Azure Powershell logged in user or service principal and executes an Azure Powershell command underneath to authenticate the application against Microsoft Entra ID.
Sample: Construct AzurePowershellCredential
The following code sample demonstrates the creation of a AzurePowerShellCredential, using the AzurePowerShellCredentialBuilder 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 powerShellCredential = new AzurePowerShellCredentialBuilder().build();
Constructor Summary
Constructor | Description |
---|---|
AzurePowerShellCredentialBuilder() |
Constructs an instance of Azure |
Method Summary
Modifier and Type | Method and Description |
---|---|
Azure |
additionallyAllowedTenants(String[] additionallyAllowedTenants)
Specifies tenants in addition to the specified tenant |
Azure |
additionallyAllowedTenants(List<String> additionallyAllowedTenants)
Specifies tenants in addition to the specified tenant |
Azure |
build()
Creates a new AzurePowerShellCredential with the current configurations. |
Azure |
tenantId(String tenantId)
Sets the tenant ID of the application. |
Methods inherited from CredentialBuilderBase
Methods inherited from java.lang.Object
Constructor Details
AzurePowerShellCredentialBuilder
public AzurePowerShellCredentialBuilder()
Constructs an instance of AzurePowerShellCredentialBuilder.
Method Details
additionallyAllowedTenants
public AzurePowerShellCredentialBuilder 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:
Returns:
additionallyAllowedTenants
public AzurePowerShellCredentialBuilder additionallyAllowedTenants(List
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:
Returns:
build
public AzurePowerShellCredential build()
Creates a new AzurePowerShellCredential with the current configurations.
Returns:
tenantId
public AzurePowerShellCredentialBuilder tenantId(String tenantId)
Sets the tenant ID of the application.
Parameters:
Returns:
Applies to
Azure SDK for Java