Skip to content

Commit 3b09ad9

Browse files
committed
edit
1 parent 8e135b0 commit 3b09ad9

File tree

1 file changed

+27
-69
lines changed

1 file changed

+27
-69
lines changed

articles/redis/scripts/create-manage-cache.md

Lines changed: 27 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -17,67 +17,42 @@ appliesto:
1717

1818
This article describes how to create or delete an Azure Redis cache instance by using the Azure CLI. The article also shows how to use the Azure CLI to get cache details including provisioning status, hostname, ports, and keys.
1919

20-
The scripts in this article use the following commands. Select the links in the table to access command documentation.
21-
22-
::: zone pivot="azure-managed-redis"
23-
24-
>[!NOTE]
25-
>The [az redisenterprise](/cli/azure/redisenterprise) commands are part of the `redisenterprise` extension for the Azure CLI, version 2.61.0 or higher. The extension automatically installs the first time you run an `az redisenterprise` command.
26-
27-
| Command | Description |
28-
|---|---|
29-
| [az group create](/cli/azure/group) | Creates a resource group to store all resources in. |
30-
| [az redisenterprise create](/cli/azure/redis) | Creates an Azure Managed Redis cache instance. |
31-
| [az redisenterprise show](/cli/azure/redis) | Shows details of an Azure Managed Redis instance. |
32-
| [az redisenterprise list-keys](/cli/azure/redis) | Lists access keys for an Azure Managed Redis instance. |
33-
| [az redisenterprise delete](/cli/azure/redis) | Deletes an Azure Managed Redis instance. |
34-
35-
::: zone-end
36-
37-
::: zone pivot="azure-cache-redis"
38-
39-
| Command | Description |
40-
|---|---|
41-
| [az group create](/cli/azure/group) | Creates a resource group to store all resources in. |
42-
| [az redis create](/cli/azure/redis) | Creates an Azure Cache for Redis instance. |
43-
| [az redis show](/cli/azure/redis) | Shows details of an Azure Cache for Redis instance. |
44-
| [az redis list-keys](/cli/azure/redis) | Lists access keys for an Azure Cache for Redis instance. |
45-
| [az redis delete](/cli/azure/redis) | Deletes an Azure Cache for Redis instance. |
46-
47-
::: zone-end
48-
4920
## Prerequisites
5021

5122
- [!INCLUDE [quickstarts-free-trial-note](~/reusable-content/ce-skilling/azure/includes/quickstarts-free-trial-note.md)]
5223
[!INCLUDE [azure-cli-prepare-your-environment-no-header.md](~/reusable-content/azure-cli/azure-cli-prepare-your-environment-no-header.md)]
24+
- Make sure you're signed in to Azure with the subscription you want to create your cache under. To use a different subscription than the one you're signed in with, run `az account set -s <subscriptionId>`, replacing `<subscriptionId>` with the subscription ID you want to use.
5325

54-
::: zone pivot="azure-managed-redis"
55-
56-
## Create an Azure Managed Redis cache
26+
## Create an Azure Redis cache
5727

5828
<!--
5929
:::code language="azurecli" source="~/azure_cli_scripts/redis-cache/create-cache/create-manage-cache.sh" id="FullScript":::
6030
This sample is broken. When it is fixed, we can fix this include.
6131
-->
32+
The cache `name` must be a string of 1-63 characters that's unique in the [Azure region](https://azure.microsoft.com/regions/). The name can contain only numbers, letters, and hyphens, must start and end with a number or letter, and can't contain consecutive hyphens.
33+
34+
The `location` should be an Azure region near other services that use your cache. Use a [sku](https://azure.microsoft.com/pricing/details/cache/) and `size` that have the appropriate features and performance for your cache.
6235

63-
The cache `name` must be a string of 1-63 characters that's unique in the region. The name can contain only numbers, letters, and hyphens, must start and end with a number or letter, and can't contain consecutive hyphens.
36+
Microsoft Entra authentication is enabled by default for new caches, and access keys authentication is disabled. You can enable access key authentication during or after cache creation, but for security and ease of use, Microsoft Entra authentication is recommended.
6437

65-
The `location` should be an [Azure region](https://azure.microsoft.com/regions/) near other services that use your cache. Use a cache [sku](https://azure.microsoft.com/pricing/details/cache/) and `size` that have the appropriate features and performance for your cache.
38+
Transport Layer Security (TLS) 1.2-1.3 encryption is enabled by default for new caches. You can enable the non-TLS port and connections during or after cache creation, but for security reasons, disabling TLS isn't recommended.
39+
40+
>[!IMPORTANT]
41+
>Use Microsoft Entra ID with managed identities to authorize requests against your cache if possible. Authorization using Microsoft Entra ID and managed identity provides better security and is easier to use than shared access key authorization. For more information about using managed identities with your cache, see [Use Microsoft Entra ID for cache authentication](../../azure-cache-for-redis/cache-azure-active-directory-for-authentication.md).
42+
43+
::: zone pivot="azure-managed-redis"
6644

6745
>[!IMPORTANT]
68-
>The following settings can be enabled or configured only at cache creation time. Gather the information you need to configure these settings before you create your cache.
69-
>
46+
>The following settings can be enabled or configured only at cache creation time. Gather the information you need to configure these settings and make sure to configure them correctly during cache creation.
7047
>- You must enable modules at the time you create the cache instance. You can't change modules or enable module configuration after you create a cache.
7148
>- Managed Redis supports two clustering policies: Enterprise or OSS. You can't change the clustering policy after you create the cache.
7249
>- If you're using the cache in a geo-replication group, you can't change eviction policies after the cache is created.
73-
>- If you're using the [RediSearch](../redis-modules.md#redisearch) module, the Enterprise cluster policy is required, and No Eviction is the only eviction policy supported.
50+
>- The [RediSearch](../redis-modules.md#redisearch) module requires the Enterprise cluster policy and No Eviction eviction policy.
7451
75-
For security reasons, Microsoft Entra authentication and Transport Layer Security (TLS) encryption are enabled by default for new caches. Access keys authentication is disabled. You can choose to to enable access key authentication or non-TLS connections during or after cache creation.
52+
The following script sets variables, then uses the [az group create](/cli/azure/group) and [az redisenterprise create](/cli/azure/redisenterprise#az-redisenterprise-create) commands to create a resource group and create a Balanced B1 Azure Managed Redis cache in the resource group.
7653

77-
>[!IMPORTANT]
78-
>Use Microsoft Entra ID with managed identities to authorize requests against your cache if possible. Authorization using Microsoft Entra ID and managed identity provides better security and is easier to use than shared access key authorization. For more information about using managed identities with your cache, see [Use Microsoft Entra ID for cache authentication](../../azure-cache-for-redis/cache-azure-active-directory-for-authentication.md).
79-
80-
The following example script sets variables, then creates a resource group and an Azure Managed Redis cache in the resource group. Putting all your app resources in the same resource group lets you easily manage or delete them together.
54+
>[!NOTE]
55+
>The [az redisenterprise](/cli/azure/redisenterprise) commands are part of the `redisenterprise` extension for the Azure CLI, version 2.61.0 or higher. The extension automatically installs the first time you run an `az redisenterprise` command.
8156
8257
```azurecli
8358
@@ -100,7 +75,7 @@ az redisenterprise create --name $cache --resource-group $resourceGroup --locati
10075

10176
## Get details for an Azure Managed Redis cache
10277

103-
The following script gets and displays details such as name, hostname, ports, and keys for an Azure Managed Redis cache.
78+
The following script uses the [az redisenterprise show](/cli/azure/redisenterprise#az-redisenterprise-show) and [az redisenterprise list-keys](/cli/azure/redisenterprise#az-redisenterprise-list-keys) commands to get and display name, hostname, ports, and keys details for an Azure Managed Redis cache.
10479

10580
```azurecli
10681
# Get details of an Azure Managed Redis cache
@@ -125,7 +100,7 @@ echo "Secondary Key:" ${keys[1]}
125100

126101
## Clean up resources
127102

128-
The following script deletes an Azure Managed Redis cache, and then deletes the resource group that contains all cache resources.
103+
The following script uses the [az group delete](/cli/azure/group) and [az redisenterprise delete](/cli/azure/redisenterprise#az-redisenterprise-delete) commands to delete an Azure Managed Redis cache, and then delete the resource group that contains all cache resources.
129104

130105
```azurecli
131106
# Delete a redis cache
@@ -134,30 +109,13 @@ az redisenterprise delete --name "$cache" --resource-group $resourceGroup -y
134109
135110
# echo "Deleting all resources"
136111
az group delete --resource-group $resourceGroup -y
137-
138112
```
139113

140114
::: zone-end
141115

142116
::: zone pivot="azure-cache-redis"
143117

144-
## Create an Azure Cache for Redis cache
145-
146-
<!--
147-
:::code language="azurecli" source="~/azure_cli_scripts/redis-cache/create-cache/create-manage-cache.sh" id="FullScript":::
148-
This sample is broken. When it is fixed, we can fix this include.
149-
-->
150-
151-
The cache `name` must be a string of 1-63 characters that's unique in the region. It can contain only numbers, letters, and hyphens, must start and end with a number or letter, and can't contain consecutive hyphens.
152-
153-
The `location` should be an [Azure region](https://azure.microsoft.com/regions/) near other services that use your cache. Use a cache [sku](https://azure.microsoft.com/pricing/details/cache/) and `size` that have the appropriate features and performance for your cache.
154-
155-
For security reasons, Microsoft Entra Authentication and TLS encryption are enabled by default for new caches. You can choose to enable access key authentication or non-TLS connections during or after cache creation.
156-
157-
>[!IMPORTANT]
158-
>Use Microsoft Entra ID with managed identities to authorize requests against your cache if possible. Authorization using Microsoft Entra ID and managed identity provides better security and is easier to use than shared access key authorization. For more information about using managed identities with your cache, see [Use Microsoft Entra ID for cache authentication](../../azure-cache-for-redis/cache-azure-active-directory-for-authentication.md).
159-
160-
The following example script sets variables, then creates a resource group and an Azure Cache for Redis cache in the resource group. Putting all your app resources in the same resource group lets you easily manage or delete them together.
118+
The following script sets variables, then uses the [az group create](/cli/azure/group) and [az redis create](/cli/azure/redis#az-redis-create) commands to create a resource group and create an Azure Cache for Redis Basic C0 cache in the resource group.
161119

162120
```azurecli
163121
@@ -174,25 +132,25 @@ size="C0"
174132
echo "Creating $resourceGroup in "$location"..."
175133
az group create --resource-group $resourceGroup --location "$location" --tags $tag
176134
177-
# Create a Basic C0 (256 MB) Redis Cache
135+
# Create a Basic C0 (256 MB) Azure Redis cache
178136
echo "Creating $cache"
179137
az redis create --name $cache --resource-group $resourceGroup --location "$location" --sku $sku --vm-size $size
180138
```
181139

182140
## Get details for an Azure Cache for Redis cache
183141

184-
The following script gets and displays details such as name, hostname, ports, and keys for an Azure Cache for Redis cache.
142+
The following script uses the [az redis show](/cli/azure/redis#az-redis-show) and [az redis list-keys](/cli/azure/redis#az-redis-list-keys) commands to get and display name, hostname, ports, and keys details for an Azure Cache for Redis cache.
185143

186144
```azurecli
187145
188-
# Get details of an Azure Cache for Redis
146+
# Get details of an Azure Cache for Redis cache
189147
echo "Showing details of $cache"
190148
az redis show --name "$cache" --resource-group $resourceGroup
191149
192-
# Retrieve the hostname and ports for an Azure Redis Cache instance
150+
# Retrieve the hostname and ports for an Azure Redis instance
193151
redis=($(az redis show --name "$cache" --resource-group $resourceGroup --query [hostName,enableNonSslPort,port,sslPort] --output tsv))
194152
195-
# Retrieve the keys for an Azure Redis Cache instance
153+
# Retrieve the keys for an Azure Redis instance
196154
keys=($(az redis list-keys --name "$cache" --resource-group $resourceGroup --query [primaryKey,secondaryKey] --output tsv))
197155
198156
# Display the retrieved hostname, keys, and ports
@@ -206,10 +164,10 @@ echo "Secondary Key:" ${keys[1]}
206164

207165
## Clean up resources
208166

209-
The following script deletes an Azure Cache for Redis cache, and then deletes the resource group that contains all cache resources.
167+
The following script uses the [az group delete](/cli/azure/group) and [az redis delete](/cli/azure/redis#az-redis-delete) commands to delete an Azure Cache for Redis cache, and then delete the resource group that contains all cache resources.
210168

211169
```azurecli
212-
# Delete a redis cache
170+
# Delete an Azure Redis cache
213171
echo "Deleting $cache"
214172
az redis delete --name "$cache" --resource-group $resourceGroup -y
215173

0 commit comments

Comments
 (0)