There are a couple options here within App Service. I won't touch on Logic Apps or Azure Automation, which also touch this space.
Azure WebJobs
This article is honestly the best explanation, but I'll summarize here.
On Demand WebJobs aka. Scheduled WebJobs aka. Triggered WebJobs
Triggered WebJobs are WebJobs which are run once when a URL is called or when the schedule property is present in schedule.job. Scheduled WebJobs are just WebJobs which have had an Azure Scheduler Job created to call our URL on a schedule, but we also support the schedule property, as mentioned previously.
Summary:
+
Executable/Script on demand
+
Scheduled executions
-
Have to trigger via .scm endpoint
-
Scaling is manual
-
VM is always required
Continuous WebJobs (non SDK)
These jobs run forever and we will wake them up when they crash. You need to enable Always On for these to work, which means running them in Basic tier and above.
Summary:
+
Executable/Script always running
-
Requires always on - Basic tier and above
-
VM is always required
Continuous WebJobs with the WebJobs SDK
These aren't anything from a "WebJobs the feature" point of view. Essentially, we have this sweet SDK we wrote targeting WebJobs which lets you execute code based on simple triggers. I'll talk about this more later on.
Summary:
+
Executable/Script always running
+
Richer logging/dashboard
+
Triggers supported along with long running tasks
-
Requires always on - Basic tier and above
-
Scaling is manual to set up
-
Getting started can be a bit tiresome
-
VM is always required
Azure WebJobs SDK
Azure WebJobs SDK is a completely separate SDK from WebJobs the platform feature. It's designed to be run in a WebJob, but can really be run anywhere. We have customers who run them on worker roles and even on prem or other clouds, though support is only best effort.
The SDK is just about making it easy to run some code in reaction to some event and make binding to services/etc. easy. This is honestly best covered in some docs, but the heart of it is that "event" + "code" nature. We've also done some cool extensiblity work, but that's secondary to the core purpose.
Summary:
- Most of these are mentioned above
+
You can extend and run whatever you want. Full control.
-
HTTP stuff is a little wonky, but it works
Azure Functions
Azure Functions is all about taking that core purpose of the WebJobs SDK, hosting it as a service, and making it easy to get started with other languages. We also introduce the "Serverless" concept here because it made a lot of sense to do so - we know how our SDK scales, so we can do intelligent things for you.
Azure Functions is a very heavily managed experience. We aren't supporting bringing your own host. Currently, we don't support custom extensions but its something we're investigating. We're opinionated about what you can and can't do, but for the things we enable, they are slick, and easy to use and manage.
Most of the "framework" things we've done to improve Functions go through the WebJobs SDK, though. For instance, we'll be uploading a new NuGet for WebJobs which really drastically increases the speed of logging, which has huge perf benefits for WebJobs SDK users. In shipping Functions as "WebJobs SDK as a Service" we've really improved a lot of experience issues.
I'm probably biased since Functions is our latest and greatest, but feel free to shoot more cons for Functions my way.
I'll probably end up publishing a blog which elaborates a bit more, but I tried to keep this as succinct as possible for this forum.
On Functions Comsumption plan, Kudu extensions are not available. However, you can update pip to be able to install all your dependencies correctly:
- Create your Python script on Functions (let's say NameOfMyFunction/run.py)
- Open a Kudu console
- Go to the folder of your script (should be d:/home/site/wwwroot/NameOfMyFunction)
- Create a virtualenv in this folder (python -m virtualenv myvenv)
- Load this venv (cd myenv/Scripts and call activate.bat)
Your shell should be now prefixed by (myvenv)
- Update pip (python -m pip install -U pip)
- Install what you need (python -m pip install flask)
Now in the Azure Portal, in your script, update the sys.path to add this venv:
import sys, os.path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname( __file__ ), 'myvenv/Lib/site-packages')))
You should be able to start what you want now.
(Reference: https://github.com/Azure/azure-sdk-for-python/issues/1044)
Edit: reading previous comment, it seems you need numpy. I just tested right now and I was able to install 1.12.1 with no issues.
Best Answer
(Other answer is a bit confusing, so writing instead of editing a lot)
Azure Functions can now run up to 10 minutes using the consumption plan by adding the
functionTimeout
setting to yourhost.json
file:Source: https://docs.microsoft.com/en-us/azure/azure-functions/functions-host-json#functiontimeout
File: host.json
Source:
https://buildazure.com/2017/08/17/azure-functions-extend-execution-timeout-past-5-minutes/
https://github.com/Azure/azure-webjobs-sdk-script/wiki/host.json