Azure webjobs vs scheduler - azure

A very simple question:
Why would someone use the Azure Scheduler if Azure WebJobs are free?
I couldnt find any topic regarding "azure webjobs vs azure scheduler"
The main difference is that the webjob contains everything that the scheduler can do:
Scheduler can make HTTP calls
WebJob can do that and more (run SQL commands, etc)

The actual scheduling bits of WebJobs are built on top of the scheduler. When you set up a Web Job on a schedule under the hood it uses the scheduler to kick it off. WebJobs provides a nice little location to host the code that gets executed. In fact, if you create WebJobs for a web site look in the Scheduler on the portal and you'll see them listed there as well.
Also note that the scheduler could call out to other systems not running Azure. If you have something running in a Cloud Service that needs to be called regularly, or even if something was hosted elsewhere (another provider or on premises) the scheduler is where you can set that up.
Regarding the cost aspect, there is a free tier to the scheduler as well: http://www.windowsazure.com/en-us/pricing/details/scheduler/.

It's 2016. The below answers are no longer accurate.
WebJobs now also has a built-in scheduler and the schedule can be defined by a cron expression.
When publishing to Azure, you can choose if you want to have the WebJob sparked off by the Scheduler or by the WebJob internal scheduler.
Important Note: The Azure Scheduler has limits to frequency of either 1hr or 1min depending on if paid or not. For the internal scheduler however, your App Service requires Always On to keep on running and firing off the job. This Always On status may affect your pricing.

Continuous jobs are monitored, and if they exit they are re-executed. In this way they act more like "services" in your local machine. There is a module that monitors and keeps your app working. Always-ON is a feature that will help your site stay alive and hence, your webjobs to continuously run.
Scheduler is used to trigger the webjobs. It uses the scheduler user account (not the back-end account). This way you can move out of the free tier for scheduler, sign up to higher tiers to suit your needs. But essentially, all the scheduler is doing is hitting an https endpoint (which is public, but required your auth).
Triggered jobs (scheduled and on demand) are invoked by an https call. These calls are load balanced - much in the same way that a web app with many instances is load balanced. Continuous jobs run concurrently by default, but can be set to be a singleton.

For Webjobs starting from version 2, there is no reason to use an Azure Scheduler anymore. As a matter of fact, the Azure Portal already flags this functionality as (Legacy).
From WebJob SDK v2 additional triggers have been introduced and one of them is TimerTrigger, which works with CRON expressions to schedule executions. This execution mode does not need any additional Azure construct, you just need the webapp to be set as AlwaysOn to guarantee the webjob to run.
Another azure service that works with TimerTriggers is Azure Functions, which is built on top of the WebJob SDK that allows a serverless execution.

Related

Azure Service that can schedule my API calls in AKS

I have this .NET long running API process/function that usually runs 30 mins in one execution that is hosted in AKS. This API is usually executed from the users coming from the front end of the app.
Due to concurrent executions from users, this is causing exhaustion of the app so I'm planning to implement a some sort of a queueing mechanism with the help of a scheduler(s).
What possibly is applicable Azure service that can execute my API in AKS on a scheduled basis (let's say every minute) and possibly check the database for some flagging values.
I need a way to check the table for some flagging value if there a currently running process or its been completed so it can process the next one, otherwise ignore the call until current on is complete.
I was looking into Azure Web Apps, Web Jobs or Batch Jobs but kinda confused which is applicable with my case.
Please advise thank you in advance.
There are a couple of options here.
Hangfire
Hangfire is an open-source library that can run background jobs in queues. In your case, you can enqueue each request from the client in a queue. Then Hangfire server will process them one by one (even with retry if the job fails). Hangfire supports SQL Server or Redis. You can query the storage to see the status of the queued jobs.
Hangfire can also run scheduled jobs, which will take care of that only one job run at a time.
Azure Service Bus
A more expensive option is to use Azure Service Bus for your queueing capability. For scheduled jobs, you can use AKS CronJobs but you will
implement the check yourself to see if there is a job already running.
Overall, I would recommend Hangfire, which can meet your requirements and is cheaper.

Many triggers in single webjob

Does having many triggers (blob, servicebus,timer) in a single webjob will reduce the performance of webjob?
Is there any way to improve performance of webjob with many triggers?
Can a heavy weight webjob be divided into smaller weight webjob?
Regard to Azure WebJobs as a feature of Azure App Service to run background job as the offical document said below.
WebJobs is a feature of Azure App Service that enables you to run a program or script in the same context as a web app, API app, or mobile app. There is no additional cost to use WebJobs.
Althought it said no additional cost, WebJob as a simple and useful feature was founded before Azure published other similar and more powerful services, which like Functions be introduced in the same doc as below.
Azure Functions provides another way to run programs and scripts. For a comparison between WebJobs and Functions, see Choose between Flow, Logic Apps, Functions, and WebJobs.
In the reference document above, the Summary section recommend its best application scenario.
Summary
Azure Functions offers greater developer productivity, more programming language options, more development environment options, more Azure service integration options, and more pricing options. For most scenarios, it's the best choice.
Here are two scenarios for which WebJobs may be the best choice:
You need more control over the code that listens for events, the JobHost object. Functions offers a limited number of ways to customize JobHost behavior in the host.json file. Sometimes you need to do things that can't be specified by a string in a JSON file. For example, only the WebJobs SDK lets you configure a custom retry policy for Azure Storage.
You have an App Service app for which you want to run code snippets, and you want to manage them together in the same DevOps environment.
For other scenarios where you want to run code snippets for integrating Azure or third-party services, choose Azure Functions over WebJobs with the WebJobs SDK.
Meanwhile, per my experience on Azure, WebJobs and Functions are only suitable for some simple and light-weight task job. For high performance requirement, Azure Batch service is a good choice to get the balance between cost and ease of use.
1. Does having many triggers (blob, servicebus,timer) in a single webjob will reduce the performance of webjob?
Provided that your webjob is not singleton. You can have multiple functions in your webjob with multiple triggers and the performance will not reduce. (provided your webapp plan is beefy enough to handle all the load.)
2.Is there any way to improve performance of webjob with many triggers? -
the best way would be to divide the webjob into smaller webjobs and each webjob having a single trigger. And scale your webjobs out (add more instances) based on load. Also in case your webjob executes within 5 mins you can also choose to use Azure Function App. Which gives a much better option. Alternatively, assuming the webjob execution takes more than 5 mins you can have your webjob exe as a docker image and provision them using logic app on demand using ACI. In this scenario you will be configuring the triggers in logic app.
1. Can a heavy weight webjob be divided into smaller weight webjob? - yes, see my previous answers.

Microsoft Azure Worker Role or Azure Scheduler for Backup and Restore?

Creating Backup and restore Azure Table Storage Scheduler, where user will schedule the job or task to backup Azure Table at particular time, from Wizard. Which way I must Prefer?
Should I use Azure Service i.e Creating WebRole and Worker Role.
In this case how to Execute Worker Role on Schedule.
Can I use Web Job with Scheduler?
How to use Azure Scheduler to achive this task? I have googled out
where in some blogs they suggested to use Scheduler with Azure
Queue.
You can use either. Azure WebJobs are simpler and easier to use and would work well for your scenario.
You can use Azure WebJob with Azure Scheduler. You can set the schedule ahead of time where the scheduler will trigger the WebJob where you can perform your backup task.
Please see these articles
http://azure.microsoft.com/en-us/documentation/articles/websites-dotnet-deploy-webjobs/#configure
http://azure.microsoft.com/en-us/documentation/articles/web-sites-create-web-jobs/#CreateScheduled
I would use the Azure Scheduler. If your are familiar with a Cron job, this is very similar. All the Azure Scheduler does is make a REST call to an end point on a schedule. This would probably be more cost affective then setting up a worker role. Also, I would make sure to take into account security when setting up the Azure Scheduler. I would pass some type of secret to the API as a parameter so that it's not open to anonymous calls (although technically it would be.) If you want to execute certain tasks during the call, then I would store them in a table in your database. The worker role came before the Azure Scheduler, so the worker role lost in my book when the scheduler was made public.
UPDATE:
Another thought, is to look into the automation option in Azure: https://msdn.microsoft.com/library/azure/dn643629.aspx
With this option you can execute PowerShell scripts:
http://azure.microsoft.com/blog/2014/08/20/azure-automation-capabilities-in-depth-the-azure-automation-powershell-cmdlets/

Difference between Azure Web Jobs and Azure Scheduler in Microsoft Azure?

Can anybody explain the difference between Azure Web Jobs and Azure Scheduler
Azure Web Jobs
Only available on Azure Websites
It is used to run code at particular intervals. E.g. a console application every day
Used to trigger and run workloads.
Mainly recommended for workloads that either scale with the website or are relatively small.
Can be persistently running if "Always On" selected, otherwise you will get the 20 min timeout.
The code that needs to be run and schedule are defined together.
Azure Scheduler
Is not tied to Websites or Cloud Services
It allows you to call a website or add a message to a storage queue
Used for triggering events or triggering small workloads (e.g. add to queue), usually to trigger larger workloads
Mainly recommended for triggering more complex workloads.
This is only a trigger, and a separate function listening to trigger events (e.g. queue's) needs to be coded separately.
For many instances I prefer to use the scheduler to push to a storage queue and a worker role on each instance takes off the queue. This keeps tasks controlled granularly and can also move up or down in scale outside of your website.
With WebJobs they scale up and down with your site and hence your background tasks can become over taxed if your website is experiencing low traffic and scaled down.
Azure Scheduler - Provides a way to easily schedule http calls in a well-defined schedule, like every hour, every Friday at 9:00 am, Once a day, ...
Azure WebJobs - Provides a way to run small to medium work load (in the form of a script: .exe, .cmd, .sh, .js, ...) at the same context of an Azure Website (but can be hosted even with an empty website).
While a WebJob can run continuously (with a process that has a while loop) and Azure will make sure this WebJob is always running (with "Always On" set).
There is also an integration between Azure scheduler and Azure WebJobs where you have a WebJob that is running some finite work and the schduler is responsible for scheduling this work (invoking the WebJob).
So in summary, the scheduler is about scheduling work and WebJobs is about running work load.

How can I set up a CRON job using Windows Azure?

Is there a way to use the windows scheduled task to kick off a url or a exe on a schedule?
Can I write a program as an exe then create a Azure VM then RDP into the Azure VM and hook it up to windows task scheduler?
Azure does have a scheduler now.
It allows invoking a Web Service over HTTP/s and post a message to a Windows Azure Storage Queue. It's very new but it can be free if you do not need the scheduler to be executed often. Otherwise it's a small monthly fee which come with scheduled task that can be up to every minute.
Things got much easier lately, please see this link https://azure.microsoft.com/en-us/services/scheduler/ to create a scheduled job in the new Azure Scheduler. There is a basic Free tier as well as some paid options but I think this is exactly what many of us were looking for. It is an excellent solution for triggering URLs with GET,POST,PUT,DELETE requests.
Just follow the simple instructions. Starting by selecting "Scheduler" from the Azure dashboard app menu:
Today the scheduler has been Azure Logic Apps:
https://learn.microsoft.com/en-us/azure/logic-apps/logic-apps-overview
If you are looking for something like a cron job (which is a job, that is being run at specific time again and again), then check out Azure Functions:
https://learn.microsoft.com/en-us/azure/azure-functions/functions-overview
Google Azure Storage Queues. They allow you to schedule jobs that will run at a later date. You can even specify when the job should run.

Resources