Skip to content

Commit f8ca501

Browse files
authored
Merge pull request #229649 from flang-msft/fxl---Github-issue---Documentation-appears-to-be-wrong-#102098
fxl---updated with a pasted in code block
2 parents 441368c + fd35c69 commit f8ca501

File tree

1 file changed

+51
-2
lines changed

1 file changed

+51
-2
lines changed

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

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,63 @@ In this scenario, you learn how to create an Azure Cache for Redis. You then lea
2525

2626
### Run the script
2727

28-
:::code language="azurecli" source="~/azure_cli_scripts/redis-cache/create-cache/create-manage-cache.sh" id="FullScript":::
28+
<!--
29+
:::code language="azurecli" source="~/azure_cli_scripts/redis-cache/create-cache/create-manage-cache.sh" id="FullScript":::
30+
This sample is broken. When it is fixed, we can fix this include.
31+
-->
32+
33+
```azurecli
34+
35+
# Variable block
36+
let "randomIdentifier=$RANDOM*$RANDOM"
37+
location="East US"
38+
resourceGroup="msdocs-redis-cache-rg-$randomIdentifier"
39+
tag="create-manage-cache"
40+
cache="msdocs-redis-cache-$randomIdentifier"
41+
sku="basic"
42+
size="C0"
43+
44+
# Create a resource group
45+
echo "Creating $resourceGroup in "$location"..."
46+
az group create --resource-group $resourceGroup --location "$location" --tags $tag
47+
48+
# Create a Basic C0 (256 MB) Redis Cache
49+
echo "Creating $cache"
50+
az redis create --name $cache --resource-group $resourceGroup --location "$location" --sku $sku --vm-size $size
51+
52+
# Get details of an Azure Cache for Redis
53+
echo "Showing details of $cache"
54+
az redis show --name "$cache" --resource-group $resourceGroup
55+
56+
# Retrieve the hostname and ports for an Azure Redis Cache instance
57+
redis=($(az redis show --name "$cache" --resource-group $resourceGroup --query [hostName,enableNonSslPort,port,sslPort] --output tsv))
58+
59+
# Retrieve the keys for an Azure Redis Cache instance
60+
keys=($(az redis list-keys --name "$cache" --resource-group $resourceGroup --query [primaryKey,secondaryKey] --output tsv))
61+
62+
# Display the retrieved hostname, keys, and ports
63+
echo "Hostname:" ${redis[0]}
64+
echo "Non SSL Port:" ${redis[2]}
65+
echo "Non SSL Port Enabled:" ${redis[1]}
66+
echo "SSL Port:" ${redis[3]}
67+
echo "Primary Key:" ${keys[0]}
68+
echo "Secondary Key:" ${keys[1]}
69+
70+
# Delete a redis cache
71+
echo "Deleting $cache"
72+
az redis delete --name "$cache" --resource-group $resourceGroup -y
73+
74+
# echo "Deleting all resources"
75+
az group delete --resource-group $resourceGroup -y
76+
77+
```
2978

3079
## Clean up resources
3180

3281
[!INCLUDE [cli-clean-up-resources.md](../../../includes/cli-clean-up-resources.md)]
3382

3483
```azurecli
35-
az group delete --name $resourceGroup
84+
az group delete --reourceg $resourceGroup
3685
```
3786

3887
## Sample reference

0 commit comments

Comments
 (0)