Search code examples
azureredisazure-worker-rolesazure-cloud-services

Setting up Redis on Azure cloud service worker role


I'm creating a cloud service where I have a worker role running some heavy processing in the background, for which i would like a Redis instance to be running locally on the worker.

What i want to do is set up the worker role project in a way that the Redis instance is installed/configured when the worker is deployed.

The redis database would be cleared on every job startup.

I've looked at the MSOpenTech redis for windows with nuget installation, but i'm unsure how i would get this working on the worker role instance. Is there a smart way to set it up, or would it be by command-line calls?

Thanks.


Solution

  • To install any software on a worker role instance, you'd need to set this up to happen as a startup task.

    You'll reference startup tasks in your ServiceDefinition.csdef file, in the <Startup> element, with a reference to your command file which installs whatever software you want (such as Redis).

    I haven't tried installing Redis in a worker role instance, so I can't comment about whether this will succeed. And you'll also need to worry about opening the right ports (whether external- or internal-facing), and scaling (e.g. what happens when you scale to two worker role instances, both running redis?). My answer is specific to how you install software on a role instance.

    More info on startup task setup is here.