Sunday, August 30, 2009

Azure Worker Roles

Have you tried it yet ?
It is a background worker process, jsut like a windows service. So you can create your background working processes just like you used with Windows Service. It is very simple to implement:

public class WorkerRole : RoleEntryPoint
{
public override void Start()
{
// This is a sample worker implementation. Replace with your logic.
RoleManager.WriteToLog("Information", "Worker Process entry point called");
while (true)
{
Thread.Sleep(10000);
RoleManager.WriteToLog("Information", "Working");
}
}
public override RoleStatus GetHealthStatus()
{
// This is a sample worker implementation. Replace with your logic.
return RoleStatus.Healthy;
}
}

As simple as that. Of course you can have your System.Timers.Timer instance or more and schedule your processing logic to start up at regular periods.

No comments: