How to deploy Redis to Windows Azure using the command line tool

Date: Tuesday, January 15, 2013, 6:06:10 PM

Tags:

Table of Contents

Redis is an open source key-value store which can easily be deployed to Windows Azure, utilizing the advanced infrastructure and scalability available in the Windows Azure cloud. In this tutorial you will learn how to deploy Redis to your Windows Azure subscription with a single command from the terminal.

Pre-requisites

You will need a Windows Azure account to deploy Redis to. If you do not already have an account a free trial is available at http://www.windowsazure.com/en-us/pricing/free-trial/ .

Setup the command line tool

The command line tool can be downloaded from https://github.com/MSOpenTech/redis .

To setup the command line tool simply unzip it to C:\RedisInstBin. You will then be able to use the included binaries via the full path to the exe. It is possible to add the bin folder to your system PATH. Doing so will not require the full exe path each time you run the command.

Download the Windows Azure Redis files

The Windows Azure enabled version of Redis is available on Github at https://github.com/MSOpenTech/redis .

There are two methods available when retrieving Redis for the command line tool. The first method allows you to provide the URL of a Github repository to use, and the second allows you to specify a local file system location for the files. If you would like to create a custom Redis configuration you will need to download the files from Github first.

In this tutorial it will be assumed that the files have been downloaded to C:\redisbin64

Prepare the configuration files

The default configuration files in C:\RedisInstBin will enable you to get Redis running in Windows Azure with the recommended configuration to meet the Windows Azure SLA requirements.

Windows Azure Service Configuration ( ServiceConfiguration.cscfg )

The service configuration file specifies the number of role instances to deploy for each role in the service, the values of any configuration settings, and the thumbprints for any certificates associated with a role.

A detailed description of the service configuration file can be found at http://msdn.microsoft.com/en-us/library/windowsazure/ee758710.aspx

Windows Azure Service Definition ( ServiceDefinition.csdef )

The Windows Azure service definition file defines the service model for an application. The file contains the definitions for the roles available to a service, specifies the service endpoints, and establishes configuration settings for the service. Configuration setting values are set in the service configuration file, as described by the Windows Azure Service Configuration Schema (.cscfg File).

A detailed description of the service definition file can be found at http://msdn.microsoft.com/en-us/library/windowsazure/ee758711.aspx

Redis configuration file ( Redis.conf )

The Redis configuration file controls how Redis operates. A detailed description of the Redis configuration file can be found at http://redis.io/topics/config

During deployment the secondary Redis server Redis.conf files will be populated automatically with the values required to connect to the primary instance.

RedisInstWA.exe parameters

RedisInstaWA.exe is the binary file that creates and deploys Redis to Windows Azure. There are six ( 6 ) parameters you should be aware of to pass to the executable.

  • Source
  • Config
    • Path to the Windows Azure configuration files. In this tutorial the path will be C:\RedisInstBin\Samples. Note: The path is to the folder containing the file.
  • RedisConf
    • Path to the Redis configuration file. In this tutorial the path will be C:\RedisInstBin\Samples. Note: The path is to the folder containing the file.
  • Emu
    • If present Redis will be deployed to the local Windows Azure emulator. -Domain and -Subscription are not necessary when using -Emu
  • Domain
    • Domain endpoint to create the Redis deployment at in Windows Azure. Only the first section of the domain is supplied. I.E. If the service will live at redisdeployment.cloudapp.net the domain should be redisdeployment
  • Subscription
    • English name provided when creating the Windows Azure subscription, not the subscription id.

RedisInstWA.exe requires access to the Web Platform Installer to ensure your machine has all the required tools and libraries. As such you will need to open a terminal as Administrator to successfully run the commands.

Deploying Redis locally

In order to deploy Redis locally you will use the -Emu option. Using the paths above, the command should look similar to the following:

C:\RedisInstBin\bin\RedisInstWA.exe - Source C:\redisbin64 -Config C:\RedisInstBin\Samples -RedisConf C:\RedisInstBin\Samples -Emu

You may be asked to allow firewall access to Redis. Allow it and your deployment will continue successfully.

Deploying Redis to Windows Azure

When you are ready to deploy to Windows Azure you simply remove the -Emu parameter and add you Domain and Subscription settings.

C:\RedisInstBin\bin\RedisInstWA.exe - Source C:\redisbin64 -Config C:\RedisInstBin\Samples -RedisConf C:\RedisInstBin\Samples -Domain redisdeployment -Subscription RedisDemoSubscription

If you placed the files in the same directory as the tutorial you need only update Domain and Subscription with your real values, the rest of the parameters will be correct.

Immediately after running the command a web browser should open and ask you to login to your Windows Azure Portal. This is necessary to download the settings required to publish the service.

This command can take several minutes. While it is running your system is being checked with the Web Platform Installer to ensure you have all the tools available. You may see a dialog asking you to approve/continue the deployment. A storage account is then created and prepped, the package uploaded, and a new Windows Azure service created at the domain you specified. After the service has successfully deploy you will be able to begin interacting with Redis as you would if it were running on any other system.

Troubleshooting

If you are having difficulty deploying your Redis service check the topics below for possible solutions.

The Windows Azure Portal contains useful operations logs. You can view the logs from the portal by clicking Settings from the left navigation menu and selecting Operation Logs from the tab in the main content area.

Fails to create service

If you see a message stating that the command failed to create the service check your Windows Azure subscription. You will see this message if you utilize all the available cores in your subscription.

Another possibility is that a service with the same name already exists. The service will not automatically be removed to prevent accidentally removing something important. Either remove the service through the portal or use a new name.

Fails to create storage

If you see a message stating the storage account failed check your Windows Azure subscription to ensure you have the ability to create additional storage accounts on your subscription.

Another possibility is that a storage account with the same name exists. Existing storage accounts will not be removed or utilized to prevent accidentally losing or corrupting data. Either remove the storage account through the portal or use a different name.

Fails to deploy to Windows Azure after running in emulator

If the emulator is running a version of your service it will lock the project directory. In order to successfully deploy simply stop the deployment running in the emulator to free up the file system lock.

 
blog comments powered by Disqus

Related Content

No related content was found