Provides authentication for Azure SDK clients in Java applications using Microsoft Entra ID and various credential patterns.
- GitHub stars
- 3,194
- Files
- 2
- Last commit
- Nov 11, 2026
- License
- MIT
- Allowed tools
- —
What does the azure-identity-java skill do?
azure-identity-java provides authentication for Azure SDK clients in Java applications using Microsoft Entra ID and various credential patterns.
Summary generated from the skill's SKILL.md.
About the azure-identity-java skill
Java developers building applications that interact with Azure services use this library to implement Microsoft Entra ID authentication. It provides a variety of credential patterns to ensure applications can securely access resources like Blob Storage or Key Vault. By integrating this library, developers can handle complex identity requirements through a unified interface, making it easier to manage security across different environments.
An agent should load this skill when tasked with writing or debugging Java code that requires Azure authentication. The library offers specific tools such as DefaultAzureCredential for a multi-method approach that works in both development and production, ManagedIdentityCredential for Azure-hosted resources like App Service or VMs, and ClientSecretCredential for service principals. It also supports specialized needs like WorkloadIdentityCredential for AKS or InteractiveBrowserCredential for desktop applications. The library relies on standard Java dependency management and can be configured via environment variables or programmatic builders to handle different cloud environments, including Azure Government and Azure China.
What an agent can do with it
- 1Implement multi-environment authenticationConfigure a single credential that works for both local development and production environments.
- 2Authenticate Azure-hosted applicationsSet up managed identity for applications running on App Service, Functions, or VMs.
- 3Secure CI/CD pipelinesUse environment variables to provide credentials during automated deployment processes.
- 4Develop desktop applicationsEnable an interactive login flow for users running desktop software.
Written from the skill's SKILL.md. Every use case is checked against a quote from it.
How to install the azure-identity-java skill
Each command copies the skill folder into the client's skills directory. Restart the client or start a new session to load it.Install the azure-identity-java skill in Claude Code
~/.claude/skills/azure-identity-java/SKILL.md
$ npx degit microsoft/skills/.github/plugins/azure-sdk-java/skills/azure-identity-java ~/.claude/skills/azure-identity-javaInstall the azure-identity-java skill in Claude Code (project)
.claude/skills/azure-identity-java/SKILL.md
$ npx degit microsoft/skills/.github/plugins/azure-sdk-java/skills/azure-identity-java .claude/skills/azure-identity-javaInstall the azure-identity-java skill in Codex
~/.agents/skills/azure-identity-java/SKILL.md
$ npx degit microsoft/skills/.github/plugins/azure-sdk-java/skills/azure-identity-java ~/.agents/skills/azure-identity-javaInstall the azure-identity-java skill in Gemini CLI
~/.gemini/skills/azure-identity-java/SKILL.md
$ npx degit microsoft/skills/.github/plugins/azure-sdk-java/skills/azure-identity-java ~/.gemini/skills/azure-identity-javaInstall the azure-identity-java skill in Claude.ai
npx degit microsoft/skills/.github/plugins/azure-sdk-java/skills/azure-identity-java azure-identity-java && zip -r azure-identity-java.zip azure-identity-java # claude.ai → Customize → Skills → + → Create skill → Upload a skill → azure-identity-java.zip
Automated checks
Ran Nov 15, 2026Full report →Passed our automated checks. That is not a security audit: read the scripts before you let an agent run them. How checks work
- Source repository linked and reachablemicrosoft/skills/.github/plugins/azure-sdk-java/skills/azure-identity-java is public and reachablegithub.com/microsoft/skills/tree/HEAD/.github/plugins/azure- ↗Pass
- Open source license (OSI)MITspdx.org/licenses/MIT.html ↗Pass
- Commit or release in the last yearLast commit 2026-11-11github.com/microsoft/skills/commits ↗Pass
- No download-and-run or credential theft in scriptsNo scripts in the skill folderPass
- No hidden instructions in SKILL.mdNo override phrases, safeguard switches, credential requests or hidden charactersgithub.com/microsoft/skills/blob/HEAD/.github/plugins/azure- ↗Pass
- Pre-approved tools are scopedNo pre-approved tools; the agent asks before using onegithub.com/microsoft/skills/blob/HEAD/.github/plugins/azure- ↗Pass
- SKILL.md follows the Agent Skills formatValid name and description; says when to use it; 358 linesgithub.com/microsoft/skills/blob/HEAD/.github/plugins/azure- ↗Pass
SKILL.md
View on GitHubAzure Identity library for Java
Authentication library for Azure SDK clients using Microsoft Entra ID.
Installation
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.15.0</version>
</dependency>
Key Concepts
| Credential | Use Case |
|---|---|
DefaultAzureCredential |
Recommended - Works in dev and production |
ManagedIdentityCredential |
Azure-hosted apps (App Service, Functions, VMs) |
EnvironmentCredential |
CI/CD pipelines with env vars |
ClientSecretCredential |
Service principals with secret |
ClientCertificateCredential |
Service principals with certificate |
AzureCliCredential |
Local dev using az login |
InteractiveBrowserCredential |
Interactive login flow |
DeviceCodeCredential |
Headless device authentication |
DefaultAzureCredential (Recommended)
The DefaultAzureCredential tries multiple authentication methods in order. See DefaultAzureCredential overview for the current credential chain order and defaults.
import com.azure.identity.DefaultAzureCredential;
import com.azure.identity.DefaultAzureCredentialBuilder;
// Simple usage
DefaultAzureCredential credential = new DefaultAzureCredentialBuilder().build();
// Use with any Azure client
BlobServiceClient blobClient = new BlobServiceClientBuilder()
.endpoint("https://<storage-account>.blob.core.windows.net")
.credential(credential)
.buildClient();
KeyClient keyClient = new KeyClientBuilder()
.vaultUrl("https://<vault-name>.vault.azure.net")
.credential(credential)
.buildClient();
Configure DefaultAzureCredential
DefaultAzureCredential credential = new DefaultAzureCredentialBuilder()
.managedIdentityClientId("<user-assigned-identity-client-id>") // For user-assigned MI
.tenantId("<tenant-id>") // Limit to specific tenant
.excludeEnvironmentCredential() // Skip env vars
.excludeAzureCliCredential() // Skip Azure CLI
.build();
Managed Identity
For Azure-hosted applications (App Service, Functions, AKS, VMs).
import com.azure.identity.ManagedIdentityCredential;
import com.azure.identity.ManagedIdentityCredentialBuilder;
// System-assigned managed identity
ManagedIdentityCredential credential = new ManagedIdentityCredentialBuilder()
.build();
// User-assigned managed identity (by client ID)
ManagedIdentityCredential credential = new ManagedIdentityCredentialBuilder()
.clientId("<user-assigned-client-id>")
.build();
// User-assigned managed identity (by resource ID)
ManagedIdentityCredential credential = new ManagedIdentityCredentialBuilder()
.resourceId("/subscriptions/<sub>/resourceGroups/<rg>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<name>")
.build();
Service Principal with Secret
import com.azure.identity.ClientSecretCredential;
import com.azure.identity.ClientSecretCredentialBuilder;
ClientSecretCredential credential = new ClientSecretCredentialBuilder()
.tenantId("<tenant-id>")
.clientId("<client-id>")
.clientSecret("<client-secret>")
.build();
Service Principal with Certificate
import com.azure.identity.ClientCertificateCredential;
import com.azure.identity.ClientCertificateCredentialBuilder;
// From PEM file
ClientCertificateCredential credential = new ClientCertificateCredentialBuilder()
.tenantId("<tenant-id>")
.clientId("<client-id>")
.pemCertificate("<path-to-cert.pem>")
.build();
// From PFX file with password
ClientCertificateCredential credential = new ClientCertificateCredentialBuilder()
.tenantId("<tenant-id>")
.clientId("<client-id>")
.pfxCertificate("<path-to-cert.pfx>", "<pfx-password>")
.build();
// Send certificate chain for SNI
ClientCertificateCredential credential = new ClientCertificateCredentialBuilder()
.tenantId("<tenant-id>")
.clientId("<client-id>")
.pemCertificate("<path-to-cert.pem>")
.sendCertificateChain(true)
.build();
Environment Credential
Reads credentials from environment variables.
import com.azure.identity.EnvironmentCredential;
import com.azure.identity.EnvironmentCredentialBuilder;
EnvironmentCredential credential = new EnvironmentCredentialBuilder().build();
Required Environment Variables
For service principal with secret:
AZURE_TENANT_ID=<tenant-id>
AZURE_CLIENT_ID=<client-id>
AZURE_CLIENT_SECRET=<client-secret>
For service principal with certificate:
AZURE_TENANT_ID=<tenant-id>
AZURE_CLIENT_ID=<client-id>
AZURE_CLIENT_CERTIFICATE_PATH=/path/to/cert.pem
AZURE_CLIENT_CERTIFICATE_PASSWORD=<optional-password>
Azure CLI Credential
For local development using az login.
import com.azure.identity.AzureCliCredential;
import com.azure.identity.AzureCliCredentialBuilder;
AzureCliCredential credential = new AzureCliCredentialBuilder()
.tenantId("<tenant-id>") // Optional: specific tenant
.build();
Interactive Browser
For desktop applications requiring user login.
import com.azure.identity.InteractiveBrowserCredential;
import com.azure.identity.InteractiveBrowserCredentialBuilder;
InteractiveBrowserCredential credential = new InteractiveBrowserCredentialBuilder()
.clientId("<client-id>")
.redirectUrl("http://localhost:8080") // Must match app registration
.build();
Device Code
For headless devices (IoT, CLI tools).
import com.azure.identity.DeviceCodeCredential;
import com.azure.identity.DeviceCodeCredentialBuilder;
DeviceCodeCredential credential = new DeviceCodeCredentialBuilder()
.clientId("<client-id>")
.challengeConsumer(challenge -> {
// Display to user
System.out.println(challenge.getMessage());
})
.build();
Chained Credential
Create custom authentication chains.
import com.azure.identity.ChainedTokenCredential;
import com.azure.identity.ChainedTokenCredentialBuilder;
ChainedTokenCredential credential = new ChainedTokenCredentialBuilder()
.addFirst(new ManagedIdentityCredentialBuilder().build())
.addLast(new AzureCliCredentialBuilder().build())
.build();
Workload Identity (AKS)
For Azure Kubernetes Service with workload identity.
import com.azure.identity.WorkloadIdentityCredential;
import com.azure.identity.WorkloadIdentityCredentialBuilder;
// Reads from AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_FEDERATED_TOKEN_FILE
WorkloadIdentityCredential credential = new WorkloadIdentityCredentialBuilder().build();
// Or explicit configuration
WorkloadIdentityCredential credential = new WorkloadIdentityCredentialBuilder()
.tenantId("<tenant-id>")
.clientId("<client-id>")
.tokenFilePath("/var/run/secrets/azure/tokens/azure-identity-token")
.build();
Token Caching
Enable persistent token caching for better performance.
// Enable token caching (in-memory by default)
DefaultAzureCredential credential = new DefaultAzureCredentialBuilder()
.enableAccountIdentifierLogging()
.build();
// With shared token cache (for multi-credential scenarios)
SharedTokenCacheCredential credential = new SharedTokenCacheCredentialBuilder()
.clientId("<client-id>")
.build();
Sovereign Clouds
import com.azure.identity.AzureAuthorityHosts;
// Azure Government
DefaultAzureCredential govCredential = new DefaultAzureCredentialBuilder()
.authorityHost(AzureAuthorityHosts.AZURE_GOVERNMENT)
.build();
// Azure China
DefaultAzureCredential chinaCredential = new DefaultAzureCredentialBuilder()
.authorityHost(AzureAuthorityHosts.AZURE_CHINA)
.build();
Error Handling
import com.azure.identity.CredentialUnavailableException;
import com.azure.core.exception.ClientAuthenticationException;
try {
DefaultAzureCredential credential = new DefaultAzureCredentialBuilder().build();
AccessToken token = credential.getToken(new TokenRequestContext()
.addScopes("https://management.azure.com/.default"));
} catch (CredentialUnavailableException e) {
// No credential could authenticate
System.out.println("Authentication failed: " + e.getMessage());
} catch (ClientAuthenticationException e) {
// Authentication error (wrong credentials, expired, etc.)
System.out.println("Auth error: " + e.getMessage());
}
Logging
Enable authentication logging for debugging.
// Via environment variable
// AZURE_LOG_LEVEL=verbose
// Or programmatically
DefaultAzureCredential credential = new DefaultAzureCredentialBuilder()
.enableAccountIdentifierLogging() // Log account info
.build();
Environment Variables
# DefaultAzureCredential configuration
AZURE_TENANT_ID=<tenant-id>
AZURE_CLIENT_ID=<client-id>
AZURE_CLIENT_SECRET=<client-secret>
# Managed Identity
AZURE_CLIENT_ID=<user-assigned-mi-client-id>
# Workload Identity (AKS)
AZURE_FEDERATED_TOKEN_FILE=/var/run/secrets/azure/tokens/azure-identity-token
# Logging
AZURE_LOG_LEVEL=verbose
# Authority host
AZURE_AUTHORITY_HOST=https://login.microsoftonline.com/
Best Practices
- Use DefaultAzureCredential - Works seamlessly from dev to production
- Managed Identity in Production - No secrets to manage, automatic rotation
- Azure CLI for Local Dev - Run
az loginbefore running your app - Least Privilege - Grant only required permissions to service principals
- Token Caching - Enabled by default, reduces auth round-trips
- Environment Variables - Use for CI/CD, not hardcoded secrets
Credential Selection Matrix
| Environment | Recommended Credential |
|---|---|
| Local Development | DefaultAzureCredential (uses Azure CLI) |
| Azure App Service | DefaultAzureCredential (uses Managed Identity) |
| Azure Functions | DefaultAzureCredential (uses Managed Identity) |
| Azure Kubernetes Service | WorkloadIdentityCredential |
| Azure VMs | DefaultAzureCredential (uses Managed Identity) |
| CI/CD Pipeline | EnvironmentCredential |
| Desktop App | InteractiveBrowserCredential |
| CLI Tool | DeviceCodeCredential |
Trigger Phrases
- "Azure authentication Java", "DefaultAzureCredential Java"
- "managed identity Java", "service principal Java"
- "Azure login Java", "Azure credentials Java"
- "AZURE_CLIENT_ID", "AZURE_TENANT_ID"
Files in this skill
2azure-identity-java skill questions
How do I install the azure-identity-java skill in Claude Code?
Run npx degit microsoft/skills/.github/plugins/azure-sdk-java/skills/azure-identity-java ~/.claude/skills/azure-identity-java. Claude Code loads skills from ~/.claude/skills (all projects) or .claude/skills (one project) and uses a skill when its description matches the task.
Which clients can use the azure-identity-java skill?
Any client that reads the Agent Skills format: Claude Code, Codex, Gemini CLI and claude.ai (upload as a ZIP). Scripts in the skill run only where the client allows code execution.
What is the recommended credential for Azure Java applications?
DefaultAzureCredential is the recommended approach because it works in both development and production environments by trying multiple authentication methods.
How can I authenticate in a CI/CD pipeline using this library?
You can use the EnvironmentCredential, which reads credentials from environment variables like AZURE_TENANT_ID, AZURE_CLIENT_ID, and AZURE_CLIENT_SECRET.
How do I use managed identity for Azure-hosted applications?
You can use ManagedIdentityCredential for services like App Service, Functions, AKS, or VMs, supporting both system-assigned and user-assigned identities.
Can I use this library for local development?
Yes, you can use AzureCliCredential which utilizes the credentials from your local 'az login' session.