Skip to content

Commit 4691f6c

Browse files
committed
redis-cli
1 parent e58186b commit 4691f6c

File tree

5 files changed

+70
-61
lines changed

5 files changed

+70
-61
lines changed
Lines changed: 61 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,123 @@
11
---
2-
title: Use redis-cli with Azure Cache for Redis
3-
description: Learn how to use *redis-cli* as a command-line tool for interacting with an Azure Cache for Redis as a client
2+
title: Use redis-cli
3+
description: Learn how to use redis-cli as a command-line tool for interacting with an Azure Cache for Redis as a client.
44

55

66

7-
ms.topic: conceptual
7+
ms.topic: how-to
88
ms.date: 01/04/2024
99
appliesto:
1010
- ✅ Azure Cache for Redis
1111
---
1212
# Use the Redis command-line tool with Azure Cache for Redis
1313

14-
Use the [redis-cli command-line tool](https://redis.io/docs/connect/cli/) to interact with an Azure Cache for Redis as a client. Use this tool to directly interact with your Azure Cache for Redis instance and for debugging and troubleshooting.
14+
This article describes how to use the [redis-cli command-line interface](https://redis.io/docs/connect/cli/) to interact with Azure Cache for Redis as a client. You can use *redis-cli* to directly interact with your Azure Redis cache instance, and for debugging and troubleshooting.
15+
16+
## Prerequisite
17+
18+
Access to an Azure Cache for Redis server instance.
1519

1620
## Install redis-cli
1721

18-
The _redis-cli_ tool is installed automatically with the _Redis package_, which is available for multiple operating systems. See the open source [install Redis](https://redis.io/docs/install/install-redis/) guide for the most detailed documentation on your preferred operating system.
22+
The redis-cli tool installs automatically with the Redis package, which is available for Linux, macOS, and Windows. For detailed installation instructions for your operating system, see the open-source [Install Redis](https://redis.io/docs/install/install-redis/) guide.
1923

20-
### Linux
24+
### Install on Linux
2125

22-
The _redis-cli_ runs natively on Linux, and most distributions include a _Redis package_ that contains the _redis-cli_ tool. On Ubuntu, for instance, you install the _Redis package_ with the following commands:
26+
The redis-cli tool runs natively on Linux, and most Linux distributions include a Redis package that contains redis-cli. On Ubuntu, for instance, you install the Redis package with the following commands:
2327

2428
```linux
2529
sudo apt-get update
2630
sudo apt-get install redis
2731
```
2832

29-
### Windows
33+
### Install on Windows
3034

31-
The best way to use _redis-cli_ on a Windows computer is to install the [Windows Subsystem for Linux (WSL)](/windows/wsl/about). The Linux subsystem allows you to run linux tools directly on Windows. To install WSL, follow the [WSL installation instructions](/windows/wsl/install).
35+
The best way to use redis-cli on Windows is to install the [Windows Subsystem for Linux (WSL2)](/windows/wsl/about), which allows you to run Linux tools directly on Windows. To install WSL, see [How to install Linux on Windows with WSL](/windows/wsl/install).
3236

33-
Once WSL is installed, you can install _redis-cli_ using whatever package management is available in the Linux distro you chose for WSL.
37+
Once installed, use WSL to install a Linux distro, and then install redis-cli by using the available package management for the Linux distro you chose. The default distro for WSL is Ubuntu. For more information, see [Install Redis on Windows](https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/install-redis-on-windows/).
3438

35-
## Gather cache access information
39+
## Connect using redis-cli
3640

37-
You can gather the information needed to access the cache using these methods:
41+
To use redis-cli to connect to your Azure Redis cache as a client, you must specify the cache host name, ports, and keys. You can retrieve these values by the following methods:
3842

3943
- Azure CLI using [az redis list-keys](/cli/azure/redis#az-redis-list-keys)
4044
- Azure PowerShell using [Get-AzRedisCacheKey](/powershell/module/az.rediscache/Get-AzRedisCacheKey)
41-
- Using the Azure portal
45+
- [Azure portal](https://portal.azure.com)
4246

43-
In this section, you retrieve the keys from the Azure portal.
47+
The following section describes how to get these values from the Azure portal.
4448

4549
[!INCLUDE [redis-cache-create](includes/redis-cache-access-keys.md)]
4650

47-
## Connect using redis-cli
51+
### Gather cache information
4852

49-
Open up a shell or terminal on a computer with the _Redis package_ installed. If using WSL, you can [use the Windows Terminal](/windows/wsl/install#ways-to-run-multiple-linux-distributions-with-wsl) to open a Linux command line. Before connecting with redis-cli, check:
53+
Before connecting to your cache via redis-cli, determine the following information so you know what command options to use.
5054

51-
1. Whether TLS access is needed - By default, Azure Cache for Redis instances use [TLS](cache-remove-tls-10-11.md) encryption for connections. Whenever TLS is used on the server side, TLS on redis-cli must be enabled using the `--tls` option.
52-
1. The port used - All Enterprise and Enterprise Flash tier caches use port `10000`. Basic, Standard, and Premium tier caches, however, use either port `6379` for non-TLS connections or port `6380` for TLS connections.
53-
1. Whether the cache instance uses clustering - If you're using a Premium tier cache that uses clustering or an Enterprise/Enterprise Flash tier cache that is using OSS cluster policy, add the `-c`option to ensure all shards can be accessed.
55+
- **TLS**: By default, Azure Redis instances use [Transport Layer Security (TLS)](cache-remove-tls-10-11.md) encryption for connections. If the cache uses TLS, you must enable TLS for redis-cli by using the `--tls` option.
56+
- **Port**: Enterprise and Enterprise Flash tier caches use port `10000`. Basic, Standard, and Premium tier caches use either port `6379` for non-TLS connections or port `6380` for TLS connections.
57+
- **Clustering**: If you have a Premium tier cache that uses clustering, or an Enterprise or Enterprise Flash tier cache that uses OSS cluster policy, add the `-c`option to ensure all shards can be accessed.
5458

55-
### Examples
59+
### Run the redis-cli connection command
5660

57-
1. Use the following command to connect to a Basic, Standard, or Premium tier Azure Cache for Redis instance using TLS:
61+
Open a shell or terminal on a computer with the Redis package installed. On Windows, you can use WSL with [Windows Terminal](/windows/wsl/install#ways-to-run-multiple-linux-distributions-with-wsl) to open a Linux command line.
62+
Run one of the following command lines, depending on your TLS, port, and clustering options. Replace the `<cache name>` and `<access key>` placeholders with the values for your cache.
5863

59-
```console
60-
redis-cli -p 6380 -h yourcachename.redis.cache.windows.net -a YourAccessKey --tls
61-
```
64+
- Connect to a Basic, Standard, or Premium tier Azure Redis instance that uses TLS:
6265

63-
1. Connect to a Basic, Standard, or Premium tier Azure Cache for Redis instance that doesn't use TLS:
66+
```console
67+
redis-cli -p 6380 -h <cache name>.redis.cache.windows.net -a <access key> --tls
68+
```
6469

65-
```console
66-
redis-cli -p 6379 -h yourcachename.redis.cache.windows.net -a YourAccessKey
67-
```
70+
- Connect to a Basic, Standard, or Premium tier Azure Redis instance that doesn't use TLS:
6871

69-
1. Connect to a Basic, Standard, or Premium tier Azure Cache for Redis instance using TLS and clustering:
72+
```console
73+
redis-cli -p 6379 -h <cache name>.redis.cache.windows.net -a <access key>
74+
```
7075

71-
```console
72-
redis-cli -p 6380 -h yourcachename.redis.cache.windows.net -a YourAccessKey --tls -c
73-
```
76+
- Connect to a Basic, Standard, or Premium tier Azure Redis instance that uses TLS and clustering:
7477

75-
1. Connect to an Enterprise or Enterprise Flash tier cache instance using Enterprise cluster policy with TLS:
78+
```console
79+
redis-cli -p 6380 -h <cache name>.redis.cache.windows.net -a <access key> --tls -c
80+
```
7681

77-
```console
78-
redis-cli -p 10000 -h yourcachename.eastus.redisenterprise.cache.azure.net -a YourAccessKey --tls
79-
```
82+
- Connect to an Enterprise or Enterprise Flash tier cache instance that uses Enterprise cluster policy with TLS:
8083

81-
1. Connect to an Enterprise or Enterprise Flash tier cache instance using OSS cluster policy without TLS:
84+
```console
85+
redis-cli -p 10000 -h <cache name>.eastus.redisenterprise.cache.azure.net -a <access key> --tls
86+
```
8287

83-
```console
84-
redis-cli -p 10000 -h yourcachename.eastus.redisenterprise.cache.azure.net -a YourAccessKey -c
85-
```
88+
- Connect to an Enterprise or Enterprise Flash tier cache instance that uses OSS cluster policy without TLS:
8689

87-
### Testing the connection
90+
```console
91+
redis-cli -p 10000 -h <cache name>.eastus.redisenterprise.cache.azure.net -a <access key> -c
92+
```
8893

89-
Once the connection is established, you can issue commands to your Azure Cache for Redis instance. One easy way to test the connection is to use the [`PING`](https://redis.io/commands/ping/) command. This command returns `PONG` in the console.
94+
You're now connected to your Azure Redis cache using redis-cli.
9095

91-
```output
92-
yourcachename.redis.cache.windows.net:6380> PING
96+
## Use redis-cli commands with your cache
97+
98+
Once you establish the connection, you can issue commands to your Azure Redis instance. One easy way to test the connection is to use the [`PING`](https://redis.io/commands/ping/) command. The following command returns `PONG` in the console.
99+
100+
```console
101+
<cache name>.redis.cache.windows.net:6380> PING
93102
PONG
94103
```
95104

96-
You can also run commands like `SET` and `GET`:
105+
You can also run commands like `SET` and `GET`.
97106

98-
```output
99-
yourcachename.redis.cache.windows.net:6380> SET hello world
107+
```console
108+
<cache name>.redis.cache.windows.net:6380> SET hello world
100109
OK
101-
yourcachename.redis.cache.windows.net:6380> GET hello
110+
<cache name>.redis.cache.windows.net:6380> GET hello
102111
"world"
103112
```
104113

105-
You're now connected to your Azure Cache for Redis instance using the _redis-cli_.
106-
107-
## redis-cli alternatives
114+
## Alternatives to redis-cli
108115

109-
While the _redis-cli_ is a useful tool, you can connect to your cache in other ways for troubleshooting or testing:
116+
You can also connect to your cache in the following other ways for troubleshooting or testing:
110117

111118
- Azure Cache for Redis offers a [Redis Console](cache-configure.md#redis-console) built into the Azure portal where you can issue commands without needing to install the command-line tool. The Redis Console feature is currently only available in the Basic, Standard, and Premium tiers.
112-
- [RedisInsight](https://redis.io/insight/) is a rich open source graphical tool for issuing Redis commands and viewing the contents of a Redis instance. It works with Azure Cache for Redis and is supported on Linux, Windows, and macOS.
119+
- [RedisInsight](https://redis.io/insight/) is a rich open-source graphical tool for issuing Redis commands and viewing the contents of a Redis instance. RedisInsight works with Azure Cache for Redis and is supported on Linux, Windows, and macOS.
113120

114121
## Related content
115122

116-
Get started by creating a [new Enterprise-tier cache](quickstart-create-redis-enterprise.md) instance.
123+
Get started by creating a [new Enterprise-tier cache](quickstart-create-redis-enterprise.md).
-14.1 KB
Loading
28.6 KB
Loading
-6.2 KB
Loading
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
---
2-
ms.date: 08/16/2024
2+
ms.date: 04/04/2025
33
ms.topic: include
44
ms.custom: ignite-2024
55
---
66

7-
### Retrieve host name, ports, and access keys from the Azure portal
7+
### Get cache host name, ports, and access keys from the Azure portal
88

9-
To connect your Azure Cache for Redis server, the cache client needs the host name, ports, and a key for the cache. Some clients might refer to these items by slightly different names. You can get the host name, ports, and keys from the [Azure portal](https://portal.azure.com).
9+
To connect to your Azure Redis cache, the cache client needs the cache host name, port, and keys. Some clients might refer to these items by slightly different names. Follow these instructions to get the cache host name, port, and keys from the [Azure portal](https://portal.azure.com).
1010

11-
- 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`.
11+
- Copy the host name and port from the cache **Overview** page in the portal. The host name is of the form `<cache name>.redis.cache.windows.net`.
1212

13-
:::image type="content" source="media/redis-cache-access-keys/redis-cache-hostname-ports.png" alt-text="Screenshot showing Azure Cache for Redis properties.":::
13+
:::image type="content" source="media/redis-cache-access-keys/redis-cache-hostname-ports.png" alt-text="Screenshot showing Azure Redis cache properties.":::
1414

15-
- To get the access keys, select **Authentication** from the **Resource** menu. Then, select the **Access keys** tab.
15+
- To get the access keys, select **Show access keys** on the **Overview** page. The **CacheKeys** pane shows the keys.
1616

17-
:::image type="content" source="media/redis-cache-access-keys/redis-cache-keys.png" alt-text="Screenshot showing Azure Cache for Redis access keys.":::
17+
You can also select **Authentication** under **Settings** in the left navigation menu, and then select the **Access keys** tab.
18+
19+
:::image type="content" source="media/redis-cache-access-keys/redis-cache-keys.png" alt-text="Screenshot showing Azure Redis cache access keys.":::

0 commit comments

Comments
 (0)