Click here to Skip to main content
Click here to Skip to main content

Azure Tutorial; Be in cloud (Part 4) [Worker Role]

, 10 Jan 2011
Rate this:
Please Sign up or sign in to vote.
 Windows Azure - Compute (Worker Role)Before we start of with the worker role, we might talk about few things over the course which we have already discussed on our previous part. If you haven't read the previous part and you aren't able to follow something, I would recommend reading the previous pa

Windows Azure - Compute (Worker Role)

Before we start of with the worker role, we might talk about few things over the course which we have already discussed on our previous part. If you haven't read the previous part and you aren't able to follow something, I would recommend reading the previous part.

As I already briefed in part 2, the worker role is basically a worker process which is normally configured to run on an infinite loop. We will create which is something similar to as we spoke.

Create an Application

As we have already created a solution, we will make you use of the same.

Now to add a project, in the solution explorer, right click on the "Roles" folder and click "Add -> New Worker Role Project". We will name it as "CloudTutorialWorker". Now as we already saw in the previous part, there will be another entry "CloudTutorialWorker" in the "Roles" folder which contain similar settings as in a web role.

We will not talk about the settings and other features about the project as we have already covered the same in the previous project.

Lets Discuss Code

Before we go ahead and run the application, we will have a look on the what the code is and how does it work.

As in a normal worker or windows service, there are two methods auto populated; "Run" and "OnStart". You can also override "OnStop" event to do functionalities on stop of the process.

In our code, it is written to show a log info "Working" every 10 seconds. Similarly we can write any process to run endlessly.

Lets go ahead and run the application. Press F5 and it will start the application as we saw in our previous part. So when you run the application, you will find the web page being shown. So how do we find the worker role running. Open the simulation environment and have a look on the "Development Fabric".

Now as in the picture we have both and the "CloudTutorialWeb" and "CloudTutorialWorker" running and if you select the worker, we could see the information popping up for every 10 seconds as we have programmed.

Now you can apply your own logic and work on the same. We will discuss more on the application while we try writing samples which will make use of the entire Azure technology.

What's Next

Now we are done with the "Worker Role" and the "Compute" section of the Azure technology. Our agenda for the next part would be on the "Storage" and we will also discuss the various options it offers and will try to code on the same.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

jebarson
Software Developer (Senior) Microsoft Corporation
India India
I work for Microsoft on MS technologies for application development. My interests include .net, WCF, Azure, Windows Phone, ASP.net, SL, WCF, WPF and many more.
 
You can visit my site at http://www.jebarson.info
 
Follow me on twitter @jebarson007
Follow on   Twitter

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 10 Jan 2011
Article Copyright 2011 by jebarson
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid