The Azure Identity library provides Microsoft Entra ID token authentication support across the Azure SDK with a comprehensive set of TokenCredential implementations.
—
DEPRECATED: Authenticates using Visual Studio Code Azure Account extension credentials. This credential is deprecated due to the underlying VS Code Azure Account extension being deprecated.
Enables authentication using cached credentials from VS Code Azure Account extension.
/**
* Visual Studio Code credential for development environments
* @deprecated VS Code Azure Account extension has been deprecated
*/
@Deprecated
class VisualStudioCodeCredential implements TokenCredential {
Mono<AccessToken> getToken(TokenRequestContext request);
// Note: Does not support synchronous getTokenSync method
}
@Deprecated
class VisualStudioCodeCredentialBuilder extends CredentialBuilderBase<VisualStudioCodeCredentialBuilder> {
VisualStudioCodeCredentialBuilder tenantId(String tenantId);
VisualStudioCodeCredentialBuilder additionallyAllowedTenants(String... additionallyAllowedTenants);
VisualStudioCodeCredentialBuilder additionallyAllowedTenants(List<String> additionallyAllowedTenants);
VisualStudioCodeCredential build();
}⚠️ This credential is deprecated because:
import com.azure.identity.VisualStudioCodeCredential;
import com.azure.identity.VisualStudioCodeCredentialBuilder;
// DEPRECATED - Not recommended for new development
@SuppressWarnings("deprecation")
TokenCredential credential = new VisualStudioCodeCredentialBuilder()
.build();
// With specific tenant
@SuppressWarnings("deprecation")
TokenCredential tenantCredential = new VisualStudioCodeCredentialBuilder()
.tenantId("your-tenant-id")
.build();
// Multi-tenant support
@SuppressWarnings("deprecation")
TokenCredential multiTenantCredential = new VisualStudioCodeCredentialBuilder()
.tenantId("primary-tenant")
.additionallyAllowedTenants("tenant1", "tenant2")
.build();Recommended Alternatives for VS Code Development:
// Modern replacement for VS Code authentication
TokenCredential credential = new AzureCliCredentialBuilder()
.build();
// Setup: Install Azure CLI and run 'az login'// Comprehensive authentication chain including Azure CLI
TokenCredential credential = new DefaultAzureCredentialBuilder()
.build();// For interactive development scenarios
TokenCredential credential = new InteractiveBrowserCredentialBuilder()
.clientId("your-client-id")
.build();Remove VisualStudioCodeCredential usage:
// Remove deprecated credential
// TokenCredential credential = new VisualStudioCodeCredentialBuilder().build();Install Azure CLI:
# Install Azure CLI for your platform
# macOS: brew install azure-cli
# Windows: winget install Microsoft.AzureCLI
# Linux: curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bashAuthenticate with Azure CLI:
az loginUpdate to use AzureCliCredential:
TokenCredential credential = new AzureCliCredentialBuilder()
.build();For maintaining existing code only:
Throws CredentialUnavailableException when:
Recommended modern setup for VS Code development:
# Install Azure CLI
az login
# Or use Azure PowerShell
Connect-AzAccountThen use:
// Use DefaultAzureCredential which includes Azure CLI
TokenCredential credential = new DefaultAzureCredentialBuilder()
.build();This provides a more reliable and supported authentication experience for development scenarios.
Install with Tessl CLI
npx tessl i tessl/maven-com-azure--azure-identitydocs