@@ -25,14 +25,63 @@ In this scenario, you learn how to create an Azure Cache for Redis. You then lea
25
25
26
26
### Run the script
27
27
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
+ ```
29
78
30
79
## Clean up resources
31
80
32
81
[ !INCLUDE [ cli-clean-up-resources.md] ( ../../../includes/cli-clean-up-resources.md )]
33
82
34
83
``` azurecli
35
- az group delete --name $resourceGroup
84
+ az group delete --reourceg $resourceGroup
36
85
```
37
86
38
87
## Sample reference
0 commit comments