Skip to main content

Different methods of creating CRON jobs on Windows Azure

In the last couple of weeks we saw a lot of new features related to Windows Azure. In this moment if want to run a task or a job on Azure we had a lot of possibilities starting from Worker Roles and ending with Web Jobs or Schedulers on Mobile Services.
In this post we will look over a part of the services that are available on Windows Azure to run different jobs. For each of them we will try to identify the best case when we can use them.

We will start with Worker Roles. Theoretically behind the Worker Role we have a VM that gives to us the full power of the CPU and Memory that is available on it. On such machines we can run the most complex jobs that we can have. On such roles we can implement any kind of jobs, without any kind of limitations. Because the VM is managed by Azure platform we don’t need to be worried about OS, security updates and so on.
I would use this kind of machines if I would need to process an audio stream, generate an ISO with a custom content or doing some heavy tasks.
Another place where we have the ability to run jobs is on Hadoop (HDInsight). On this service we can run jobs that are consuming a lot of resources to process different content. For example if we have a data source (like a job) from where we need to extract some statistical information. This jobs perfect option for us when we have a lot of input data and based on it we need to extract reports or statistical information.
I would use Hadoop for jobs that need to process large amounts of logs data to extract different reports.
In Mobile Services we have the ability to schedule and run different jobs. They are very similar with CRON jobs and can be written in JavaScript. The jobs that can be run from Mobile Services are very simple and are oriented to the mobile service and mobile applications. This means that the job should be very simple and would process the data only for a user or for a limited number of users. For example this jobs are great if you need to update different fields from customers table or clean some tables.
But you shouldn't use this job to process pictures or make long call requests to different jobs (for example call 10-20 different external services and send clients data). You should use the jobs from Mobil Services at your application level. For more complicated jobs, you should try to use other solutions.
Azure Scheduler is something like a scheduler. Basically, this is the scheduler mechanism that gives you the ability to call a custom URL at a specific time interval. You will not be able to define the action that needs to be executed, only the endpoint that needs to be called. The endpoint that can be called can be an HTTP, HTTPs endpoint or a queue. For queues you have the ability to specify the body content of the message that is added to the queue.
This can be used with success in combination with Worker Roles (using queues) or WebJobs. For example if we have a cleaning task that needs to be executed every 4 days, we can define an Azure Scheduler that will call a specific URL of our site every 4 days. The URL will trigger our custom clean action.
The last available mechanism to define and run a job or a task is by Web Jobs. Using Web Jobs we have the ability to run any task on the web instances where we run our application. It is important to know that the Web Jobs will run on the same instances that we host our application. Because of this we need to be aware of what kind of tasks we want to run using Web Jobs. We don’t want to have tasks that consume a lot of resources from our instances and put our web application down. The good part is that the load balancer from Windows Azure will select the instances that has the lowest load. Like Mobile Services “CRON’ jobs, Web Jobs are recommended to use for small and simple jobs. For complex jobs we can use with success worker roles of HDInsight.

In this post we saw different ways to define a job/task. We don’t have a best solution, based on our needs we need to know to select the solution that is more suitable for us.


Popular posts from this blog

ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded

Today blog post will be started with the following error when running DB tests on the CI machine:
threw exception: System.InvalidOperationException: The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See for more information. at System.Data.Entity.Infrastructure.DependencyResolution.ProviderServicesFactory.GetInstance(String providerTypeName, String providerInvariantName) This error happened only on the Continuous Integration machine. On the devs machines, everything has fine. The classic problem – on my machine it’s working. The CI has the following configuration:

TeamCity.NET 4.51EF 6.0.2VS2013
It seems that there …

How to check in AngularJS if a service was register or not

There are cases when you need to check in a service or a controller was register in AngularJS.
For example a valid use case is when you have the same implementation running on multiple application. In this case, you may want to intercept the HTTP provider and add a custom step there. This step don’t needs to run on all the application, only in the one where the service exist and register.
A solution for this case would be to have a flag in the configuration that specify this. In the core you would have an IF that would check the value of this flag.
Another solution is to check if a specific service was register in AngularJS or not. If the service was register that you would execute your own logic.
To check if a service was register or not in AngularJS container you need to call the ‘has’ method of ‘inhector’. It will return TRUE if the service was register.
if ($injector.has('httpInterceptorService')) { $httpProvider.interceptors.push('httpInterceptorService&#…

Fundamental Books of a Software Engineer (version 2018)

More then six years ago I wrote a blog post about fundamental books that any software engineer (developer) should read. Now it is an excellent time to update this list with new entries.

There are 5 different categories of books, that represent the recommended path. For example, you start with Coding books, after that, you read books about Programming, Design and so on.
There are some books about C++ that I recommend not because you shall know C++, only because the concepts that you can learn from it.


Writing solid codeCode completeProgramming Pearls, more programming pearls(recommended)[NEW] Introduction to Algorithms


Refactoring (M. Fowler)Pragmatic ProgrammerClean code[NEW] Software Engineering: A Practitioner's Approach[NEW] The Mythical Man-Month[NEW] The Art of Computer Programming


Applying UML and Patterns (GRASP patterns)C++ coding standards (Sutter, Alexandrescu)The C++ programming language (Stroustrup, Part IV)Object-oriented programming (Peter Coad)P…