1

We are moving a web app over to Azure and would like some feedback on our strategy. Azure is new to us and so we want to make sure that we are going down the right path. Note that we're using VS 2010.

Our current app has two parts: 1) a standard web app for the user interface and 2) a windows app that runs on the server. The windows app wakes up every 2 minutes, looks for any new records in a SQL table, processes them and then sleeps. The windows app also tells us the number of records processed, processing time, etc so that we can see the general health of the system. Both apps read/write files stored on the server. (Yes, this should probably be a service but we wanted the interface so we can quickly see overall health. We have a service that checks to make sure the interface is running and restarts it if there's a failure.)

Porting the web app to Azure is straight forward and we've done some testing on it within VS without any problems. We need some advice on the windows app and setting up/accessing the files.

Here's our strategy. All advice is appreciated.

1 - Create a worker role for the windows app. 2 - Set this worker role as the startup project. 3 - The worker role will create the Azure cloud drive (for file access) and pass the drive letter to the web app. We'll establish the connection within onstart. 4 - Make certain that the worker role is persistent so that we don't lose the cloud drive.

Two additional questions:

1 - It appears that a worker role can have a user interface but perhaps we're misreading something. If we attempt to add the windows app to the solution we receive a number of errors. We also tried to create a worker role and set it as a Windows Form Application but that immediately produced an error about their being no 'Main' method which was a warning flag to us that we shouldn't be doing this. What are we missing here?

2 - If the worker role is set as the startup project, will it need to start the web app or will that start automatically once the worker role has completed its startup processing?

David Makogon
  • 69,407
  • 21
  • 141
  • 189
Jon Leach
  • 821
  • 2
  • 10
  • 21

1 Answers1

2

Web and Worker roles are basically Windows Server 2008 SP2 / R2 VMs, with Web Roles having IIS configured and running. The actual webrole.cs and workerrole.cs code you have is just scaffolding that's run when the web role / worker role instances are booted. You also have startup scripts that can handle elevated-privilege tasks (such as modifying the registry and installing software).

Regarding your strategy: You don't have to create a worker role for your Windows Service, though you should consider it if you feel there would be a performance issue. You could choose to run it in your web role - just kick off the thread from your OnStart() or Run(). You'll need to ensure that only one single scheduler is running. There are numerous SO questions about running a scheduler in Windows Azure, such as this one, and some that discuss the use of quartz.net, as this one does.

Regarding a cloud drive being shared: One role cannot share a drive letter with another role. And with cloud drives, there can only be one writer. Each role instance, in fact, would need its own cloud drive. this is an area where you may want to consider blob storage for common-file storage.

Per your mention of a worker role not having a UI: While Visual Studio doesn't facilitate adding web apps to a worker role, you could do it. More importantly: Since a worker role is just a Windows Server VM, there's nothing stopping you from running any number of alternative web servers (such as tomcat, jetty, and jboss). You'd just need to run these either from a startup script, or from OnStart() by launching a process. You'd also need to create Input Endpoints as needed (e.g. http port 80, https 443). You could just as easily run these servers in a web role (and run any other type of port server that supports tcp, udp, http, or https).

Regarding startup project: Your cloud project would be the startup project. Web and worker role instances start up in parallel.

Community
  • 1
  • 1
David Makogon
  • 69,407
  • 21
  • 141
  • 189