public final class DefaultAzureCredential
extends ChainedTokenCredential
DefaultAzureCredential simplifies authentication while developing apps that deploy to Azure by combining credentials used in Azure hosting environments with credentials used in local development. In production, it's better to use something else. For more information, see Usage guidance for DefaultAzureCredential.
Attempts to authenticate with each of these credentials, in the following order, stopping when one provides a token:
Consult the documentation of these credentials for more information on how they attempt authentication.
Configure DefaultAzureCredentialDefaultAzureCredential supports a set of configurations through setters on the DefaultAzureCredentialBuilder or environment variables.
AZURE_CLIENT_ID
, AZURE_CLIENT_SECRET/AZURE_CLIENT_CERTIFICATE_PATH
, and AZURE_TENANT_ID
configures the DefaultAzureCredential to authenticate as the service principal specified by the values.AZURE_TENANT_ID
configures the DefaultAzureCredential to authenticate to a specific tenant for Visual Studio Code, and IntelliJ IDEA.Sample: Construct DefaultAzureCredential
The following code sample demonstrates the creation of a DefaultAzureCredential, using the DefaultAzureCredentialBuilder 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 defaultAzureCredential = new DefaultAzureCredentialBuilder().build();
Sample: Construct DefaultAzureCredential with User Assigned Managed Identity
User-Assigned Managed Identity (UAMI) in Azure is a feature that allows you to create an identity in Microsoft Entra ID that is associated with one or more Azure resources. This identity can then be used to authenticate and authorize access to various Azure services and resources. The following code sample demonstrates the creation of a DefaultAzureCredential to target a user assigned managed identity, using the DefaultAzureCredentialBuilder 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 dacWithUserAssignedManagedIdentity
= new DefaultAzureCredentialBuilder().managedIdentityClientId("<Managed-Identity-Client-Id").build();
Methods inherited from ChainedTokenCredential Methods inherited from java.lang.Object Applies to
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide. In this articleWas this page helpful?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4