Windows Azure has a project type i.e. worker role. Worker role applications are background processing application like windows process which runs on the background.
In this article I am going to explain how to create worker role project and the various fundamental methods which are executed in worker role projects.
Follow the steps given below to create or add Worker role in windows azure:
· Open Microsoft Visual Studio 2010 as an administrator.
· To create a new project File – New – Project.
· Select Cloud template from the Installed Templates.
· Select Windows Azure Project and enter the name of the project as WorkRoleExample.
· Click OK to proceed.
· To add a worker role to the solution, choose Worker Role and then choose the right arrow. The roles are displayed in the Windows Azure solution pane of the dialog box.
· Click OK to add.
In the below code snippet we have created a simple 'WorkerRole' class which inherits from 'RoleEntryPoint'.
public class WorkerRole : RoleEntryPoint
{
int intLoop = 0;
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
intLoop = 5;
bool result = true;
while (result)
{
Thread.Sleep(1000);
Trace.WriteLine("This is loop number " + intLoop, "Information");
intLoop--;
if (intLoop == 0)
result = false;
}
return base.OnStart();
}
}
After modifying the code in WorkerRole class, press F5 in order to debug your application. While debugging an application open Output window (Ctrl + W + O). The output should something like below:
To check the running instance, open the shortcut menu for the Windows Azure icon in the notification area and then choose Show Compute Emulator UI.
The Windows Azure Compute Emulator is displayed.
Here you can also check the output as output indicated with the white line in the above figure.
After reading this article you can easily create and use worker role in a windows azure application. I think this will help a lot.
John Smith
28-Aug-2012http://www.mindstick.com/Articles/e9b613f0-9072-4982-8cc6-f453aad41368/?Host%20WCF%20in%20a%20Windows%20Service%20Using%20TCP
http://www.mindstick.com/Articles/c3a59412-0895-4256-9e4b-3f95f7a8cbef/?WCF%20%28Windows%20Communication%20Foundation%29%20%E2%80%93%20Overview%20and%20Sample%20Code%20in%20C#%20.NET
http://www.mindstick.com/Articles/a0e46f74-f76e-4804-a3ed-ccd0738c0d36/?Creating%20%E2%80%9CHello%20World%E2%80%9D%20WCF%20Application
http://www.mindstick.com/Articles/0e246b74-e99c-41bb-95ea-92d5b4aad4d0/?Introduction%20to%20WCF
anil babu
28-Aug-2012Chris Anderson
28-Aug-2012http://www.mindstick.com/Articles/0c3ac0b4-4294-4443-897d-c9947533f006/?DML%20and%20DQL%20using%20Table%20Service%20in%20Windows%20Azure#dvHeaderText
anil babu
28-Aug-2012Chris Anderson
28-Aug-2012Hi,
'OnStart' method is executed the first time when your worker role is executed. It means it invoked only once when your worker role is started or executed.
anil babu
27-Aug-2012anil babu
27-Aug-2012