Wednesday, 30 October 2013

Using Scheduled Task on a Web Role to replace Azure Worker Role for background job.

In this post i'll explain how to deploy Schedule tast .exe on web role to replace the worker role for background job.

create one Web project there just create your task folder and past your ".exe" task and "config" to that folder like follows 



then create one start-up task for that to make the task run for every particular time or every day or every month by giving command to make execute 
for example if you want to execute that task for every 10mins use this commant

@echo off
REM ********************************************************
REM Start the Task Scheduler Service
REM ********************************************************
net start "task scheduler"
REM ********************************************************
REM Create scheduled tasks.
REM ********************************************************
SCHTASKS /Create /SC MINUTE /MO 10 /TN TaskScheduler /TR "%~dp0TaskRunner.exe" /RU SYSTEM /F /RL HIGHEST

To create an startup task file use notepad and save it as ".CMD" form them it will create the file.
and add startup in your webrole "servicedefinition.csdef" file add below code under your webrole.

<Startup>
      <Task commandLine="TaskScheduler .cmd" executionContext="elevated" />
</Startup>



then do deploy your web role in azure like previous post i explained. thanks for reading. 

No comments:

Post a Comment