Scheduling a long running task in Azure - azure

I am very new in Azure. I have got a requirement to extract all ADO Workitems for all projects under the domain. I did it using WIQL and personal access token in C#. But the extraction takes around 1 hr to fetch everything for the last few years. Thats fine..
But the trouble is I have no idea how to make it schedule to run early morning every day (Outside business hours). Earlier we have got a dedicated server and thus I made the app a console app and used Task scheduler to run that every morning. But in Azure, please suggest a best and easy solution.
Developed in .NET Core 3.0

Azure webjobs will solve this problem you can enable the trigger to run automatically. Follow below article for step by step:
Micorsoft Document Reference
Using CRON jobs you step the schedule your task early morning

For this requirement, you can create a azure timer trigger function with cron expression which you want. Do your task in function code, the function will be executed according to the cron expression.
When you create the function app, please choose app service plan but not consumption plan because function in consumption plan can just run maximum 10 minutes and you mentioned your task will take about 1 hour. So choose app service plan and set the value of property functionTimeout as -1 in the host.json of your function.
By the way, you'd better also enable "Always on" of your function app because you need the function long running.

Related

Turn On Function (Resource) at a Specific Time of The Day

We have over 20 functions inside one function in each environment and yes I'm aware of the timer trigger. What I'm looking for is a way to turn on the azure function resource itself (not the functions inside the function) at a specific time of the day, and turn off the azure function resource itself at a specific time of the day.
We tried looking for a way to do this in through azure devops CI pipeline (which is usually how we turn on and off the azure function resource itself) as you can see here but its not yet supported atm
You can use the Azure App Service Actions within a Logic App to Create schedule-based and recurring automation workflows with Azure Logic Apps.
These actions can also (re)start or stop an Azure Function App.
The example in the screenshot runs once every day at 12:00 and starts the Function App called gtmooaf01.

Azure - Dynamically get a schedule from database and trigger multiple methods to do different tasks in azure?

What is the best way of using Azure technology (azure function apps, durable function app, azure web jobs, ?) to get a schedule from a database depending on the specific task that needs to be performed.
The schedule that would be read from the database, would then be converted to a CRON expression. I have hourly, daily, and weekly triggers to run specific tasks.
The schedule within the database could possibly change, hence why it would need to be dynamic.
I could create individual specific function apps (over 20) but wanting it to be more flexible and dynamic.
How would i go about this? what azure tech would i use?
Thanks
Two options I can think of, depending on the details of what you're after:
Use timer-triggered Azure Functions with the %appsetting% format for the timer expression. Then have a separate function that's timed to run regularly or triggered when the schedules update, get the current schedule and update the function app settings with any changes to the CRON expressions (using a managed identity that gives it the necessary permissions).
If you're just running on the hour/day/week, you could have a function that runs every hour, reads the current schedule and triggers any functions that are scheduled for that time (basically your own simple timer).

Best & Cost effective way to run long running process

I have SharePoint list. I have written a windows service, which runs every 5 minutes and read new/modified list items from SharePoint and insert into SQL database.
Which one of the below service will be best and cost effective way to run long running service on azure?
VM
Scheduler
Web app/ web job
Worker role/ Web role
Batch
Thanks,
Kannan Eswar.
I'd suggest using either a WebJobs [1] or a Function App [2].
The downside to creating an entire VM to host the service is you'll need to pay to keep the VM running. WebJobs and Functions will both be cheaper and can both be scheduled to execute your task every 5 minutes. If there is not much code involved for the task, I'd look at creating a function in a Function App.
[1] https://learn.microsoft.com/en-us/azure/app-service-web/web-sites-create-web-jobs
[2] https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer

Azure webjobs vs scheduler

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.

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