Skip to content

Commit a37e5db

Browse files
committed
draft
1 parent 116dcc2 commit a37e5db

File tree

1 file changed

+61
-67
lines changed

1 file changed

+61
-67
lines changed
Lines changed: 61 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
2-
title: Create, query, and delete an Azure Redis cache - Azure CLI
3-
description: This Azure CLI code sample shows how to create an Azure Managed Redis instance using the command az redisenterprise create. It then gets details of an Azure Managed Redis instance, including provisioning status, the hostname, ports, and keys for an Azure Redis instance. Finally, it deletes the cache.
2+
title: Create, query, and delete a cache using Azure CLI
3+
description: These Azure CLI code samples show how to create an Azure Managed Redis or Azure Cache for Redis instance, get cache details like status, hostname, ports, and keys, and delete the cache.
44

55

66
ms.devlang: azurecli
77
ms.topic: sample
8-
ms.date: 03/11/2022
8+
ms.date: 05/05/2025
99
zone_pivot_groups: redis-type
1010
ms.custom: devx-track-azurecli, ignite-2024
1111
appliesto:
@@ -15,41 +15,50 @@ appliesto:
1515

1616
# Create an Azure Redis cache using the Azure CLI
1717

18-
In this scenario, you learn how to create an Azure Redis cache instance. You then learn to get details of the cache, including provisioning status, the hostname, ports, and keys for the cache. Finally, you learn to delete the cache.
18+
This article describes how how to create or delete an Azure Redis cache instance by using the Azure CLI. The article also shows how to use the CLI to get cache details including provisioning status, hostname, ports, and keys.
1919

20-
[!INCLUDE [quickstarts-free-trial-note](~/reusable-content/ce-skilling/azure/includes/quickstarts-free-trial-note.md)]
21-
22-
[!INCLUDE [azure-cli-prepare-your-environment.md](~/reusable-content/azure-cli/azure-cli-prepare-your-environment.md)]
23-
24-
## Sample script
20+
The scripts in this article uses the following commands. Select the links in the table to access command-specific documentation.
2521

2622
::: zone pivot="azure-managed-redis"
2723

28-
## Azure Managed Redis
29-
30-
[!INCLUDE [managed-redis-create](../includes/managed-redis-create.md)]
24+
| Command | Description |
25+
|---|---|
26+
| [az group create](/cli/azure/group) | Creates a resource group to store all resources in. |
27+
| [az redisenterprise create](/cli/azure/redis) | Creates an Azure Managed Redis cache instance. |
28+
| [az redisenterprise show](/cli/azure/redis) | Shows details of an Azure Managed Redis instance. |
29+
| [az redisenterprise list-keys](/cli/azure/redis) | Lists access keys for an Azure Managed Redis instance. |
30+
| [az redisenterprise delete](/cli/azure/redis) | Deletes an Azure Managed Redis instance. |
3131

3232
::: zone-end
3333

3434
::: zone pivot="azure-cache-redis"
3535

36-
## Azure Cache for Redis
37-
38-
[!INCLUDE [redis-cache-create](~/reusable-content/ce-skilling/azure/includes/azure-cache-for-redis/includes/redis-cache-create.md)]
36+
| Command | Description |
37+
|---|---|
38+
| [az group create](/cli/azure/group) | Creates a resource group to store all resources in. |
39+
| [az redis create](/cli/azure/redis) | Creates an Azure Cache for Redis instance. |
40+
| [az redis show](/cli/azure/redis) | Shows details of an Azure Cache for Redis instance. |
41+
| [az redis list-keys](/cli/azure/redis) | Lists access keys for an Azure Cache for Redis instance. |
42+
| [az redis delete](/cli/azure/redis) | Deletes an Azure Cache for Redis instance. |
3943

4044
::: zone-end
4145

42-
::: zone pivot="azure-managed-redis"
46+
## Prerequisites
4347

44-
[!INCLUDE [cli-launch-cloud-shell-sign-in.md](~/reusable-content/ce-skilling/azure/includes/cli-launch-cloud-shell-sign-in.md)]
48+
- [!INCLUDE [quickstarts-free-trial-note](~/reusable-content/ce-skilling/azure/includes/quickstarts-free-trial-note.md)]
49+
[!INCLUDE [azure-cli-prepare-your-environment-no-header.md](~/reusable-content/azure-cli/azure-cli-prepare-your-environment.md)]
4550

46-
### Run the script
51+
::: zone pivot="azure-managed-redis"
52+
53+
## Create an Azure Managed Redis cache
4754

4855
<!--
4956
:::code language="azurecli" source="~/azure_cli_scripts/redis-cache/create-cache/create-manage-cache.sh" id="FullScript":::
5057
This sample is broken. When it is fixed, we can fix this include.
5158
-->
5259

60+
The following example script sets variables, then creates a resource group and an Azure Managed Redis cache in the resource group.
61+
5362
```azurecli
5463
5564
# Variable block
@@ -64,11 +73,17 @@ sku="Balanced_B1"
6473
echo "Creating $resourceGroup in "$location"..."
6574
az group create --resource-group $resourceGroup --location "$location" --tags $tag
6675
67-
# Create a Balanced B1 Azure Managed Redis Cache
76+
# Create a Balanced B1 Azure Managed Redis cache
6877
echo "Creating $cache"
6978
az redisenterprise create --name $cache --resource-group $resourceGroup --location "$location" --sku $sku
79+
```
7080

71-
# Get details of an Azure Managed Redis
81+
## Get details for an Azure Managed Redis cache
82+
83+
The following script gets and displays details such as name, hostname, ports, and keys for an Azure Managed Redis cache.
84+
85+
```azurecli
86+
# Get details of an Azure Managed Redis cache
7287
echo "Showing details of $cache"
7388
az redisenterprise show --name "$cache" --resource-group $resourceGroup
7489
@@ -86,48 +101,35 @@ echo "SSL Port:" ${redis[3]}
86101
echo "Primary Key:" ${keys[0]}
87102
echo "Secondary Key:" ${keys[1]}
88103
89-
# Delete a redis cache
90-
echo "Deleting $cache"
91-
az redisenterprise delete --name "$cache" --resource-group $resourceGroup -y
92-
93-
# echo "Deleting all resources"
94-
az group delete --resource-group $resourceGroup -y
95-
96104
```
97105

98106
## Clean up resources
99107

100-
[!INCLUDE [cli-clean-up-resources.md](~/reusable-content/ce-skilling/azure/includes/cli-clean-up-resources.md)]
108+
The following script deletes an Azure Managed Redis cache, and then deletes the resource group that contains all cache resources.
101109

102110
```azurecli
103-
az group delete --resource-group $resourceGroup
104-
```
105-
106-
## Sample reference
111+
# Delete a redis cache
112+
echo "Deleting $cache"
113+
az redisenterprise delete --name "$cache" --resource-group $resourceGroup -y
107114
108-
This script uses the following commands to create a resource group and an Azure Managed Redis. Each command in the table links to command specific documentation.
115+
# echo "Deleting all resources"
116+
az group delete --resource-group $resourceGroup -y
109117
110-
| Command | Notes |
111-
|---|---|
112-
| [az group create](/cli/azure/group) | Creates a resource group in which all resources are stored. |
113-
| [az redisenterprise create](/cli/azure/redis) | Create Azure Managed Redis instance. |
114-
| [az redisenterprise show](/cli/azure/redis) | Retrieve details of an Azure Managed Redis instance. |
115-
| [az redisenterprise list-keys](/cli/azure/redis) | Retrieve access keys for an Azure Managed Redis instance. |
116-
| [az redisenterprise delete](/cli/azure/redis) | Delete Azure Managed Redis instance. |
118+
```
117119

118120
::: zone-end
119121

120122
::: zone pivot="azure-cache-redis"
121123

122-
[!INCLUDE [cli-launch-cloud-shell-sign-in.md](~/reusable-content/ce-skilling/azure/includes/cli-launch-cloud-shell-sign-in.md)]
123-
124-
### Run the script
124+
## Create an Azure Cache for Redis cache
125125

126126
<!--
127127
:::code language="azurecli" source="~/azure_cli_scripts/redis-cache/create-cache/create-manage-cache.sh" id="FullScript":::
128128
This sample is broken. When it is fixed, we can fix this include.
129129
-->
130130

131+
The following example script sets variables, then creates a resource group and an Azure Cache for Redis cache in the resource group.
132+
131133
```azurecli
132134
133135
# Variable block
@@ -146,6 +148,13 @@ az group create --resource-group $resourceGroup --location "$location" --tags $t
146148
# Create a Basic C0 (256 MB) Redis Cache
147149
echo "Creating $cache"
148150
az redis create --name $cache --resource-group $resourceGroup --location "$location" --sku $sku --vm-size $size
151+
```
152+
153+
## Get details for an Azure Cache for Redis cache
154+
155+
The following script gets and displays details such as name, hostname, ports, and keys for an Azure Cache for Redis cache.
156+
157+
```azurecli
149158
150159
# Get details of an Azure Cache for Redis
151160
echo "Showing details of $cache"
@@ -164,7 +173,13 @@ echo "Non SSL Port Enabled:" ${redis[1]}
164173
echo "SSL Port:" ${redis[3]}
165174
echo "Primary Key:" ${keys[0]}
166175
echo "Secondary Key:" ${keys[1]}
176+
```
177+
178+
## Clean up resources
167179

180+
The following script deletes an Azure Managed Redis cache, and then deletes the resource group that contains all cache resources.
181+
182+
```azurecli
168183
# Delete a redis cache
169184
echo "Deleting $cache"
170185
az redis delete --name "$cache" --resource-group $resourceGroup -y
@@ -174,30 +189,9 @@ az group delete --resource-group $resourceGroup -y
174189
175190
```
176191

177-
## Clean up resources
178-
179-
[!INCLUDE [cli-clean-up-resources.md](~/reusable-content/ce-skilling/azure/includes/cli-clean-up-resources.md)]
180-
181-
```azurecli
182-
az group delete --resource-group $resourceGroup
183-
```
184-
185-
## Sample reference
186-
187-
This script uses the following commands to create a resource group and an Azure Cache for Redis. Each command in the table links to command specific documentation.
188-
189-
| Command | Notes |
190-
|---|---|
191-
| [az group create](/cli/azure/group) | Creates a resource group in which all resources are stored. |
192-
| [az redis create](/cli/azure/redis) | Create Azure Managed Redis instance. |
193-
| [az redis show](/cli/azure/redis) | Retrieve details of an Azure Managed Redis instance. |
194-
| [az redis list-keys](/cli/azure/redis) | Retrieve access keys for an Azure Managed Redis instance. |
195-
| [az redis delete](/cli/azure/redis) | Delete Azure Managed Redis instance. |
196-
197192
::: zone-end
198193

199-
## Next steps
200-
201-
For more information on the Azure CLI, see [Azure CLI documentation](/cli/azure).
194+
## Related content
202195

203-
For an Azure Managed Redis CLI script sample that creates a Azure Managed Redis with clustering, see [Azure Managed Redis with Clustering](../../azure-cache-for-redis/scripts/create-manage-premium-cache-cluster.md)
196+
- For more information about the Azure CLI, see the [Azure CLI documentation](/cli/azure).
197+
- For an Azure Managed Redis CLI script sample that creates an Azure Managed Redis cache with clustering, see [Azure Managed Redis with clustering](../../azure-cache-for-redis/scripts/create-manage-premium-cache-cluster.md).

0 commit comments

Comments
 (0)