Microsoft Entra ID for Redis Authentication on Java

Published on
Dec 24, 2025

Microsoft's cloud service Azure has long offered Azure Cache for Redis, which the company describes as a "fully managed, open source-compatible in-memory data store" that uses Redis. While the service is still available, Azure Managed Redis is a newer, enterprise-focused offering from Microsoft. Businesses and developers who opt for the newer service can leverage Microsoft Entra ID for authentication and enterprise-grade identity management.

Redis lacks native support for Java, which would seem to exclude a large group of developers from using Azure Managed Redis and Microsoft Entra ID. However, the Redisson Java client solves this problem, offering full Redis support via familiar classes and methods — including the ability to use Microsoft Entra ID for Redis authentication on Java.

What Is Microsoft Entra ID?

Microsoft Entra ID, formerly known as Azure Active Directory (Azure AD), is the identity and access management (IAM) solution for the Azure platform. Like other IAM products, Entra ID offers centralized user management, along with the ability to control access to applications and other resources.

With its lineage based in Microsoft's Active Directory and Azure AD, Entra ID offers a familiar IAM environment that many developers and sysadmins are comfortable with. In addition to its authentication and access control capabilities, Entra ID supports cloud-first and hybrid environments, as well as automated identity governance and compliance management features, making it an appealing IAM solution for businesses that use a Microsoft-heavy tech stack.

Azure Managed Redis vs. Azure Cache for Redis

In Microsoft's popular Azure cloud ecosystem, Azure Cache for Redis is the established, generally available (GA) data store service based on Redis. Azure Cache for Redis offers multiple pricing and feature tiers, allowing Azure customers to choose a cost-effective solution that best meets their application development needs.

Azure Managed Redis is a newer Redis offering built on the Redis Enterprise stack. It offers support for Redis 7.4 and higher, along with enterprise-class features like optimizations for multiple CPUs. Microsoft claims that Azure Managed Redis can provide a lower total cost of ownership (TCO) for customers deploying high-performance applications.

Microsoft Entra ID authentication is available on Azure Managed Redis, but only with the Enterprise and Enterprise Flash tiers of Azure Managed Redis.

Authenticating With Redisson and Microsoft Entra ID

The Java client Redisson makes it simple to authenticate against Microsoft Entra ID. Here is a code sample Java developers can use:

TokenAuthConfig tokenAuthConfig = EntraIDTokenAuthConfigBuilder.builder()
        .clientId("a7b3c9d2-4e5f-6a7b-8c9d-0e1f2a3b4c5d")
        .secret("xY9~pQr8.sTu3-vWx2_amNo5")
        .authority("https://login.microsoftonline.com/9f8e7d6c-5b4a-3c2d-1e0f-a9b8c7d6e5f4")
        .scopes(Collections.singleton("https://redis.azure.com/.default"))
        .build();

TokenManager tm = new TokenManager(tokenAuthConfig.getIdentityProviderConfig().getProvider(),
                                   tokenAuthConfig.getTokenManagerConfig());
EntraIdCredentialsResolver resolver = new EntraIdCredentialsResolver(tm);

Config c = new Config();
c.useSingleServer()
        .setCredentialsResolver(resolver)
        .setAddress("redis://test.redis.cache.windows.net:6379");

RedissonClient redisson = Redisson.create(c);

// perform operations

RBucket bucket = redisson.getBucket("simpleObject");
bucket.set("This is object value");

RMap map = redisson.getMap("simpleMap");
map.put("mapKey", "This is map value");

String objectValue = bucket.get();
System.out.println("stored object value: " + objectValue);

String mapValue = map.get("mapKey");
System.out.println("stored map value: " + mapValue);

redisson.shutdown();

tm.stop();

To use this code, you'll first need to obtain an access token from Microsoft Entra ID for your application. This token is then used as the password for your Redis connection. This method offers a more secure alternative to using static passwords, as the tokens are short-lived and centrally managed through Entra ID.

The Redis Solution for Java Developers on Azure

Whether in cloud platforms like Azure or self-hosted deployments, Redisson is the solution for Java developers who want to use Valkey or Redis in their applications.

Similar articles