Exercise - Set up Azure Cache for Redis
In this unit, you create an Azure Cache for Redis instance by using the Azure CLI. You can use the Azure portal to do the same configuration. The Azure Cache for Redis instance takes a while to create, so you can run the following commands and let the deployment proceed while you learn more about Azure Cache for Redis.
Set up the Azure CLI
Make sure you have the Azure CLI installed. You can check your Azure CLI version by running az --version
.
- In a Bash shell, run
az login
to sign in to your Azure subscription. - After you sign in, run
az account show
to see the subscription you're signed in to. If you want to use a different subscription, runaz account set --subscription <preferred subscription>
.
Create an Azure Cache for Redis instance
To standardize input and limit typing, set up three environment variables.
AZ_RESOURCE_GROUP
: The name for a resource group to contain your Azure resources.AZ_LOCATION
: The name of the Azure region that you want to use. The default location iseastus
, but you can choose a region closer to you for better performance. Useaz account list-locations
to list all available regions.AZ_REDIS_NAME
: A name for your Azure Cache for Redis instance. The name must be unique across all Azure Cache for Redis instances. Consider using your username as part of the name. The name must be 1 to 63 characters long and can contain only lowercase letters, numbers, and hyphens.
Substitute your own values for the following example values:
AZ_RESOURCE_GROUP=myResourceGroup AZ_LOCATION=eastus AZ_REDIS_NAME=myUsernameRedis
After you set the variables, run the following commands to create an Azure resource group and Azure Cache for Redis instance:
az group create \ --name $AZ_RESOURCE_GROUP \ --location $AZ_LOCATION az redis create \ --resource-group $AZ_RESOURCE_GROUP \ --name $AZ_REDIS_NAME \ --location $AZ_LOCATION \ --sku Basic \ --vm-size c0
This command takes a while to complete. Continue to the next unit to learn more about Azure Cache for Redis while the deployment finishes.