RobVious
RobVious

Reputation: 12915

Getting Started with Azure: Worker Role

I'm new to Azure. I have a script that automatically installs Apache, Ruby, and configures both to run a basic Ruby on Rails project. This script currently runs on Windows Server.

I'm now trying to get this working in Azure. I've signed up for a subscription, and in Visual Studio I've opened a new Worker Role project.

I'm a little stuck now though.

1) Where should I place the installation files and project files (ruby, apache, etc)? 2) Where is the best place to put the script?

Any help would be appreciated. Thank you for your time :)

Upvotes: 1

Views: 349

Answers (1)

David Makogon
David Makogon

Reputation: 71031

Within a Visual Studio project, you have three places to get things up and running:

  • Startup script. This runs before your workerrole.cs methods get called. It's ideal for installing software requiring elevated permissions, tweaking the registry, etc. For apache, there's no need for elevated permissions - it's just xcopy plus environment variables.
  • workerrole.cs OnStart() - this handler gets called prior to your role instances being added to the load balancer. You can download your apache zip from blob storage, unzip to a local folder, get it started up.
  • workerrole.cs Run() - same as OnStart() but your role instances are now in the load balancer. I wouldn't recommend setting up a web server here.

Things are a bit different when setting up tomcat from Eclipse, as there's no workerrole.cs. Instead, you have a startup script. Supplied with the Windows Azure plugin for Eclipse are several sample scripts: one for tomcat, one for JBoss, etc. You can then look at how those sample scripts setup the environment and launch the web server.

One bit of guidance: while you can package tomcat, ruby, and other runtime bits with your deployment, this also grows deployment size. I typically put 3rd-party bits in blob storage and then download them to my role instances at startup. This download is extremely fast. This also affords me the ability to update these bits without needing to redeploy (for instance: tomcat has already gone through a half-dozen incremental updates since I pushed up a deployment a few months ago; I just upload a new tomcat zip and recycle my role instances).

Upvotes: 2

Related Questions