Skip to content

Commit 074ba64

Browse files
authored
Merge pull request #293293 from backwind1233/support-amr
Add Support for Azure Managed Redis
2 parents 171b547 + 4f6f513 commit 074ba64

File tree

3 files changed

+76
-12
lines changed

3 files changed

+76
-12
lines changed

articles/azure-cache-for-redis/cache-java-get-started.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ ms.date: 01/04/2022
77
ms.topic: quickstart
88
ms.devlang: java
99
ms.custom: devx-track-java, devx-track-javaee, mode-api, mvc, devx-track-extended-java, ignite-2024
10+
zone_pivot_groups: redis-type
1011
---
1112

1213
# Quickstart: Use Azure Cache for Redis in Java with Jedis Redis client
@@ -22,10 +23,24 @@ Clone the repo [Java quickstart](https://github.com/Azure-Samples/azure-cache-re
2223
- Azure subscription - [create one for free](https://azure.microsoft.com/free/)
2324
- [Apache Maven](https://maven.apache.org/download.cgi)
2425

25-
## Create an Azure Cache for Redis
26+
::: zone pivot="azure-managed-redis"
27+
28+
## Create an Azure Managed Redis (preview) instance
29+
30+
[!INCLUDE [managed-redis-create](includes/managed-redis-create.md)]
31+
32+
::: zone-end
33+
34+
::: zone pivot="azure-cache-redis"
35+
36+
## Create an Azure Cache for Redis instance
2637

2738
[!INCLUDE [redis-cache-create](~/reusable-content/ce-skilling/azure/includes/azure-cache-for-redis/includes/redis-cache-create.md)]
2839

40+
[!INCLUDE [redis-cache-access-keys](includes/redis-cache-access-keys.md)]
41+
42+
::: zone-end
43+
2944
## Set up the working environment
3045

3146
[!INCLUDE [redis-setup-working-environment](includes/redis-setup-working-environment.md)]
@@ -54,13 +69,13 @@ Clone the repo [Java quickstart](https://github.com/Azure-Samples/azure-cache-re
5469
<dependency>
5570
<groupId>com.azure</groupId>
5671
<artifactId>azure-identity</artifactId>
57-
<version>1.11.2</version> <!-- {x-version-update;com.azure:azure-identity;dependency} -->
72+
<version>1.15.0</version> <!-- {x-version-update;com.azure:azure-identity;dependency} -->
5873
</dependency>
5974

6075
<dependency>
6176
<groupId>redis.clients</groupId>
6277
<artifactId>jedis</artifactId>
63-
<version>5.1.0</version> <!-- {x-version-update;redis.clients:jedis;external_dependency} -->
78+
<version>5.2.0</version> <!-- {x-version-update;redis.clients:jedis;external_dependency} -->
6479
</dependency>
6580
```
6681

@@ -72,7 +87,7 @@ Clone the repo [Java quickstart](https://github.com/Azure-Samples/azure-cache-re
7287
<dependency>
7388
<groupId>redis.clients</groupId>
7489
<artifactId>jedis</artifactId>
75-
<version>5.1.0</version> <!-- {x-version-update;redis.clients:jedis;external_dependency} -->
90+
<version>5.2.0</version> <!-- {x-version-update;redis.clients:jedis;external_dependency} -->
7691
</dependency>
7792
```
7893

@@ -112,9 +127,10 @@ Clone the repo [Java quickstart](https://github.com/Azure-Samples/azure-cache-re
112127

113128
String cacheHostname = System.getenv("REDIS_CACHE_HOSTNAME");
114129
String username = System.getenv("USER_NAME");
130+
int port = Integer.parseInt(System.getenv().getOrDefault("REDIS_CACHE_PORT", "6380"));
115131

116132
// Connect to the Azure Cache for Redis over the TLS/SSL port using the key.
117-
Jedis jedis = new Jedis(cacheHostname, 6380, DefaultJedisClientConfig.builder()
133+
Jedis jedis = new Jedis(cacheHostname, port, DefaultJedisClientConfig.builder()
118134
.password(token) // Microsoft Entra access token as password is required.
119135
.user(username) // Username is Required
120136
.ssl(useSsl) // SSL Connection is Required
@@ -165,9 +181,10 @@ Clone the repo [Java quickstart](https://github.com/Azure-Samples/azure-cache-re
165181
boolean useSsl = true;
166182
String cacheHostname = System.getenv("REDIS_CACHE_HOSTNAME");
167183
String cachekey = System.getenv("REDIS_CACHE_KEY");
184+
int port = Integer.parseInt(System.getenv().getOrDefault("REDIS_CACHE_PORT", "6380"));
168185

169186
// Connect to the Azure Cache for Redis over the TLS/SSL port using the key.
170-
Jedis jedis = new Jedis(cacheHostname, 6380, DefaultJedisClientConfig.builder()
187+
Jedis jedis = new Jedis(cacheHostname, port, DefaultJedisClientConfig.builder()
171188
.password(cachekey)
172189
.ssl(useSsl)
173190
.build());

articles/azure-cache-for-redis/cache-java-redisson-get-started.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ ms.topic: quickstart
88
ms.devlang: java
99
ms.custom: mvc, seo-java-january2024, seo-java-february2024, mode-api, devx-track-java, devx-track-extended-java, devx-track-javaee, ignite-2024
1010
#Customer intent: As a Java developer, new to Azure Cache for Redis, I want to create a new Java app that uses Azure Cache for Redis and Redisson as Redis client.
11+
zone_pivot_groups: redis-type
1112
---
1213

1314
# Quickstart: Use Azure Cache for Redis in Java with Redisson Redis client
@@ -24,10 +25,24 @@ This quickstart uses the Maven archetype feature to generate the scaffolding for
2425
- [Use Microsoft Entra ID for cache authentication](cache-azure-active-directory-for-authentication.md)
2526
- [Apache Maven](https://maven.apache.org/download.cgi)
2627

27-
## Create an Azure Cache for Redis
28+
::: zone pivot="azure-managed-redis"
29+
30+
## Create an Azure Managed Redis (preview) instance
31+
32+
[!INCLUDE [managed-redis-create](includes/managed-redis-create.md)]
33+
34+
::: zone-end
35+
36+
::: zone pivot="azure-cache-redis"
37+
38+
## Create an Azure Cache for Redis instance
2839

2940
[!INCLUDE [redis-cache-create](~/reusable-content/ce-skilling/azure/includes/azure-cache-for-redis/includes/redis-cache-create.md)]
3041

42+
[!INCLUDE [redis-cache-access-keys](includes/redis-cache-access-keys.md)]
43+
44+
::: zone-end
45+
3146
## Set up the working environment
3247

3348
[!INCLUDE [redis-setup-working-environment](includes/redis-setup-working-environment.md)]
@@ -57,13 +72,13 @@ This quickstart uses the Maven archetype feature to generate the scaffolding for
5772
<dependency>
5873
<groupId>com.azure</groupId>
5974
<artifactId>azure-identity</artifactId>
60-
<version>1.11.2</version> <!-- {x-version-update;com.azure:azure-identity;dependency} -->
75+
<version>1.15.0</version> <!-- {x-version-update;com.azure:azure-identity;dependency} -->
6176
</dependency>
6277

6378
<dependency>
6479
<groupId>org.redisson</groupId>
6580
<artifactId>redisson</artifactId>
66-
<version>3.27.0</version> <!-- {x-version-update;org.redisson:redisson;external_dependency} -->
81+
<version>3.36.0</version> <!-- {x-version-update;org.redisson:redisson;external_dependency} -->
6782
</dependency>
6883
```
6984

@@ -75,7 +90,7 @@ This quickstart uses the Maven archetype feature to generate the scaffolding for
7590
<dependency>
7691
<groupId>org.redisson</groupId>
7792
<artifactId>redisson</artifactId>
78-
<version>3.27.0</version> <!-- {x-version-update;org.redisson:redisson;external_dependency} -->
93+
<version>3.36.0</version> <!-- {x-version-update;org.redisson:redisson;external_dependency} -->
7994
</dependency>
8095
```
8196

@@ -149,7 +164,7 @@ This quickstart uses the Maven archetype feature to generate the scaffolding for
149164
// Connect to the Azure Cache for Redis over the TLS/SSL port using the key
150165
Config redissonconfig = new Config();
151166
redissonconfig.useSingleServer()
152-
.setAddress(String.format("rediss://%s:6380", System.getenv("REDIS_CACHE_HOSTNAME")))
167+
.setAddress(String.format("rediss://%s:%s", System.getenv("REDIS_CACHE_HOSTNAME"), System.getenv("REDIS_CACHE_PORT")))
153168
.setUsername(System.getenv("USER_NAME")) // (Required) Username is Object ID of your managed identity or service principal
154169
.setPassword(token); // Microsoft Entra access token as password is required.
155170
return redissonconfig;
@@ -213,7 +228,7 @@ This quickstart uses the Maven archetype feature to generate the scaffolding for
213228
// Connect to the Azure Cache for Redis over the TLS/SSL port using the key
214229
Config redissonconfig = new Config();
215230
redissonconfig.useSingleServer().setPassword(System.getenv("REDIS_CACHE_KEY"))
216-
.setAddress(String.format("rediss://%s:6380", System.getenv("REDIS_CACHE_HOSTNAME")));
231+
.setAddress(String.format("rediss://%s:%s", System.getenv("REDIS_CACHE_HOSTNAME"), System.getenv("REDIS_CACHE_PORT")));
217232
return redissonconfig;
218233
}
219234
}

articles/azure-cache-for-redis/includes/redis-setup-working-environment.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,28 @@ The following steps show you how to set up the working environment for the Java
88

99
### [Microsoft Entra ID authentication (recommended)](#tab/entraid)
1010

11+
::: zone pivot="azure-managed-redis"
12+
13+
```bash
14+
export REDIS_CACHE_HOSTNAME=<your-host-name>.redis.cache.windows.net
15+
export USER_NAME=<user-name>
16+
export REDIS_CACHE_PORT=10000
17+
```
18+
19+
::: zone-end
20+
21+
::: zone pivot="azure-cache-redis"
22+
23+
1124
```bash
1225
export REDIS_CACHE_HOSTNAME=<your-host-name>.redis.cache.windows.net
1326
export USER_NAME=<user-name>
27+
export REDIS_CACHE_PORT=6380
1428
```
1529

30+
::: zone-end
31+
32+
1633
Replace the placeholders with the following values:
1734

1835
- `<your-host-name>`: The DNS host name. To get the host name and ports for your cache, select **Overview** from the **Resource** menu. The host name is of the form `<DNS name>.redis.cache.windows.net`.
@@ -31,11 +48,26 @@ Replace the placeholders with the following values:
3148

3249
### [Access key authentication](#tab/accesskey)
3350

51+
::: zone pivot="azure-managed-redis"
52+
53+
```bash
54+
export REDIS_CACHE_HOSTNAME=<your-host-name>.redis.cache.windows.net
55+
export REDIS_CACHE_KEY=<your-primary-access-key>
56+
export REDIS_CACHE_PORT=10000
57+
```
58+
59+
::: zone-end
60+
61+
::: zone pivot="azure-cache-redis"
62+
3463
```bash
3564
export REDIS_CACHE_HOSTNAME=<your-host-name>.redis.cache.windows.net
3665
export REDIS_CACHE_KEY=<your-primary-access-key>
66+
export REDIS_CACHE_PORT=6380
3767
```
3868

69+
::: zone-end
70+
3971
Replace the placeholders with the following values:
4072

4173
- `<your-host-name>`: The DNS host name. To get the host name and ports for your cache, select **Overview** from the **Resource** menu. The host name is of the form `<DNS name>.redis.cache.windows.net`.

0 commit comments

Comments
 (0)