azure-redis-cli ๐
redis-cli + stunnel for easy connectivity to Azure Cache for Redis
TLDR ๐
docker run --rm -it acanthamoeba/azure-redis-cli <cache_name> <key>
Detailed Usage ๐
# Swap these vars as needed
REDIS=noel
RG=redis
# Get key
KEY=$(az redis list-keys -n $REDIS -g $RG --query 'primaryKey' -o tsv)
# Launch redis-cli
docker run --rm -it acanthamoeba/azure-redis-cli $REDIS $KEY
Extra credit ๐
Add this to your .bashrc
/.zshrc
function azure-redis-cli() {
REDIS=$1
RG=$(az redis list --query '[?name==`tempvm`].resourceGroup' -o tsv)
KEY=$(az redis list-keys -n $REDIS -g $RG --query 'primaryKey' -o tsv)
# Launch redis-cli
docker run --rm -it acanthamoeba/azure-redis-cli $REDIS $KEY
}
Then use via azure-redis-cli <cache_name>
- no password required!
Dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM redis:5-alpine | |
RUN apk add stunnel | |
COPY start.sh /start.sh | |
ENTRYPOINT ["/start.sh"] |
start.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
SERVER=$1 | |
PASS=$2 | |
tee /etc/stunnel/stunnel.conf <<EOF | |
[redis-cli] | |
client = yes | |
accept = 127.0.0.1:6380 | |
connect = $SERVER.redis.cache.windows.net:6380 | |
EOF | |
stunnel | |
redis-cli -p 6380 -a $PASS |