Skip to content

Files

Latest commit

7571434 · Jul 31, 2018

History

History
38 lines (29 loc) · 1.71 KB

redis-cache-access-keys_cli.md

File metadata and controls

38 lines (29 loc) · 1.71 KB
title description services author ms.service ms.topic ms.date ms.author ms.custom
include file
include file
redis-cache
wesmc7777
cache
include
03/28/2018
wesmc
include file

Retrieve host name, ports, and access keys using Azure CLI

To retrieve the host name and ports using the Azure CLI you can call az redis show, and to retrieve the keys you can call az redis list-keys. The following script calls these two commands and echos the hostname, ports, and keys to the console.

#/bin/bash

# Retrieve the hostname, ports, and keys for contosoCache located in contosoGroup

# Retrieve the hostname and ports for an Azure Redis Cache instance
redis=($(az redis show --name contosoCache --resource-group contosoGroup --query [hostName,enableNonSslPort,port,sslPort] --output tsv))

# Retrieve the keys for an Azure Redis Cache instance
keys=($(az redis list-keys --name contosoCache --resource-group contosoGroup --query [primaryKey,secondaryKey] --output tsv))

# Display the retrieved hostname, keys, and ports
echo "Hostname:" ${redis[0]}
echo "Non SSL Port:" ${redis[2]}
echo "Non SSL Port Enabled:" ${redis[1]}
echo "SSL Port:" ${redis[3]}
echo "Primary Key:" ${keys[0]}
echo "Secondary Key:" ${keys[1]}

For more information about this script, see Get the hostname, ports, and keys for Azure Redis Cache. For more information on Azure CLI see Install Azure CLI and Get started with Azure CLI.