WebJobs in Depth Boston Code Camp 25 April 2, 2016 - Jason Haley
Agenda What are WebJobs? How do you create WebJobs? How do you deploy them? Kudu WebJobs SDK WebJobs SDK Extensions
What are WebJobs? Flexible way to run background jobs Can be .cmd, .bat, .exe, .ps1, .sh, .php, .py, .js, .jar Execution options: continuous, on demand, scheduled Can scale with your website https://github.com/mspnp/azure-guidance/blob/master/Background-Jobs.md
Demo WebJob – Console App
How are they stored and started? WebJobs are stored within the website Site\wwwroot\App_Data\jobs\{job_type}\{job_name} Will find the file to run by (first one found wins): First look for a file called run.{supported extension} If not found, look for any file with supported extension If not found, then not a runnable WebJob
Many Options for Deploying Azure Portal Visual Studio Visual Studio Team Services – Build FTP Dropbox Drag-n-drop in Kudu Others …
Demo Deploying
Paths & Files File/Path disable.job Existence of file stops the job. Deleting it starts the job. settings.job Allows you to indicate: is_singleton to scale with website. { “is_singleton”: true } or { “is_singleton”: false } site\wwwroot\App_Data\jobs\continuous Path for continuous web jobs site\wwwroot\App_Data\jobs\triggered Path for on demand and scheduled web jobs data\jobs Data directories for jobs job_log.txt Text file of web job log status_{hash} Status file WebJobsSDK.marker Singleton lock file https://github.com/projectkudu/kudu/wiki/WebJobs-API http://channel9.msdn.com/Shows/Azure-Friday/Azure-WebJobs-105-Scaling-out-Web-Jobs https://github.com/Azure/azure-webjobs-sdk https://github.com/Azure/azure-webjobs-sdk-extensions
Kudu Engine behind git deployments and WebJobs Can be run outside of Azure Provides dashboard functionality for a website Project Site https://github.com/projectkudu/kudu
Demo Kudu
WebJob SDK A method can be “triggered” by some event Route parameters and bindings help simplify inputs and outputs A few options for logging that surface information in the Azure Portal http://blogs.msdn.com/b/jmstall/archive/2014/01/28/trigger-bindings-and-route-parameters-in-azurejobs.aspx http://blogs.msdn.com/b/jmstall/archive/2014/02/18/azure-storage-bindings-part-1-blobs.aspx and http://blogs.msdn.com/b/jmstall/archive/2014/04/17/how-does-blobinput-work.aspx http://blogs.msdn.com/b/jmstall/archive/2014/02/18/azure-storage-bindings-part-2-queues.aspx http://blogs.msdn.com/b/jmstall/archive/2014/03/06/azure-storage-bindings-part-3-tables.aspx
WebJob SDK – Triggers and Bindings Queues (Storage and ServiceBus) Blobs Tables Project Site: https://github.com/Azure/azure-webjobs-sdk http://blogs.msdn.com/b/jmstall/archive/2014/01/28/trigger-bindings-and-route-parameters-in-azurejobs.aspx http://blogs.msdn.com/b/jmstall/archive/2014/02/18/azure-storage-bindings-part-1-blobs.aspx and http://blogs.msdn.com/b/jmstall/archive/2014/04/17/how-does-blobinput-work.aspx http://blogs.msdn.com/b/jmstall/archive/2014/02/18/azure-storage-bindings-part-2-queues.aspx http://blogs.msdn.com/b/jmstall/archive/2014/03/06/azure-storage-bindings-part-3-tables.aspx
Demo WebJobs SDK
WebJob SDK Extensions TimerTrigger FileTrigger SendGrid ErrorTrigger WebHooks Project Site: https://github.com/Azure/azure-webjobs-sdk-extensions http://blogs.msdn.com/b/jmstall/archive/2014/01/28/trigger-bindings-and-route-parameters-in-azurejobs.aspx http://blogs.msdn.com/b/jmstall/archive/2014/02/18/azure-storage-bindings-part-1-blobs.aspx and http://blogs.msdn.com/b/jmstall/archive/2014/04/17/how-does-blobinput-work.aspx http://blogs.msdn.com/b/jmstall/archive/2014/02/18/azure-storage-bindings-part-2-queues.aspx http://blogs.msdn.com/b/jmstall/archive/2014/03/06/azure-storage-bindings-part-3-tables.aspx
WebJobs SDK Extensions Demo WebJobs SDK Extensions
Resources Azure WebJobs resources: http://bit.ly/1KdUkIH https://github.com/Azure/azure-webjobs-sdk-samples http://channel9.msdn.com/Events/Microsoft-Azure/AzureConf-2014/Microsoft-Azure-Web-Jobs-the-new-way-to-run-your-workloads-in-the-Cloud