4

All the documentation (eg http://azure.microsoft.com/en-us/documentation/articles/websites-dotnet-webjobs-sdk-get-started/) and sample projects for the Azure WebJobs SDK refers to hooks and bindings to Azure Storage (Tables, Blogs and Queues). I am interested in using WebJobs for functions that have nothing to do with these storage mechanisms, for example running calculations, calling services, or using them with other storage services that the WebJobs SDK doesn't have hooks for. In these cases is there any value in using the WebJobs SDK at all? I was under the (maybe incorrect) impression that the sdk gave you a number of other benefits for managing execution of the jobs themselves, like control over running with blocking in a single thread vs. running in background, etc, maybe operational hooks related to starting and stopping jobs, and some hooks into Visual Studio, etc. I know that I can upload standalone EXEs and script files and run them as WebJobs but I further assumed that running in this way was more opaque and gave you less visibility into the job executions as well as giving less programmatic ability to control them.

Is there a reason to use the WebJobs SDK outside of it's hooks to Azure Table, Blog and Queue storage services? If so, where is that documentation?

Emilio
  • 1,951
  • 3
  • 18
  • 24
  • I've moved my WorkerRole code almost with no modifications. I did not include WebJobs SDK in my project. No reason to use it if you don't need it. – trailmax Aug 12 '14 at 00:31
  • @trailmax - So did you just upload the code manually through the portal or did you do it from Visual Studio? – Emilio Aug 12 '14 at 14:21
  • I've got a PowerShell routine that includes Web-Job as part of the site package and deploys it via Azure PowerShell commands. – trailmax Aug 12 '14 at 15:10

3 Answers3

8

Following are some more details which I hope will answer your question.

The WebJobs SDK has a binding and trigger system which works with Microsoft Azure Storage Blobs, Queues and Tables as well as Service Bus. The binding system makes it easy to write code that reads or writes Microsoft Azure Storage objects using BCL types. The trigger system calls a function in your code whenever any new data is received in a Queue or Blob.

The SDK also provides a rich diagnostics and monitoring experience without having the developer write any diagnostics and logging code.

Right now we have Triggers for specific systems such as the ones mentioned above but you can write more Triggers and Bindings yourself. We will build upon this scenario and provide a rich extensibility story in the future so you can write Triggers for your own system/ scenario such as SqlServer and more.

An example of a case where you do not have to use Azure Storage is as follows. This prototype shows a FileWatcher which shows how you can Trigger a function when a new file is detected in a directory. https://github.com/rustd/WebJobsSDKSamples/tree/master/FileWatcher

You can also use JobHost.RunOnBackgroundThread or JobHost.Call() to process anything in the background. The SDK will give you the benefit of logging, managing the execution of these functions such as cancelling these functions if they are long running and never finish, without having to kill the process. We are adding async support soon so your functions can return Task as well.

You can use the SDK in WebJobs. The WebJobs platform gives you process management such as starting/ stopping a WebJob and other benefits such as scaling a WebJob and more.

As you mentioned if you just upload standalone EXEs, you will not get as much visibility into function details and logging.

pranav rastogi
  • 4,124
  • 23
  • 23
  • Your answer is exactly the clarification I have been looking for. Now I understand that using the WebJobs SDK gives me capabilities beyond just the bindings and triggers for Azure Storage. – Emilio Aug 12 '14 at 17:31
  • Hi @rustd - JobHost.RunOnBackgroundThread must be a private method, these are the ones exposed in : Microsoft.Azure.WebJobs.Host.dll, v1.0.0.0 off Nuget: `public Task StartAsync(CancellationToken cancellationToken = null); public Task StopAsync();` Are you aware of any WebJob samples using Async? – OzBob Dec 04 '14 at 05:57
2

To use the Azure Websites WebJobs feature you don't have to use the WebJobs SDK.

WebJobs SDK currently supports Azure storage queues, blobs, table and Azure service-bus queues, if you don't require any of these you don't need to use it.

Amit Apple
  • 9,034
  • 41
  • 50
  • Thanks for your response - I appreciate it. I've seen you give similar answers in other posts, however your statement "WebJobs SDK supports Azure storage queues, blobs, table and Azure service-bus queues" is very misleading (I am saying this constructively). It should say, "WebJobs SDK supports Azure storage queues, blobs, table and Azure service-bus queues AS TRIGGER MECHANISMS". The way your statement reads, a person who is not skilled in WebJobs would think that they can't even access SQL databases from within WebJobs, which isn't true. – Emilio Aug 12 '14 at 14:17
  • I edited your response but when I went to edit my comment to you to indicate this, it wouldn't let me, hence this new comment. – Emilio Aug 12 '14 at 17:01
  • As Victor mentions, WebJobs SDK is more than just triggering mechanism based on Azure storage/service-bus, it also supports output to Azure storage and has great logging mechanism, my answer is only about whether you need to use **WebJobs SDK** when not using Azure storage. – Amit Apple Aug 13 '14 at 17:47
  • My point simply is that your statement will be misleading to many people not experienced in WebJobs. I think you are close to it so you may not be considering their point of view. I have seen numerous responses online (in response to you making the same statement elsewhere or from other people stating it the same way) saying, "So I can't use SQL Azure from WebJobs??" Yes I know you are saying that the "SDK" only supports Azure storage, but most people read that as "WebJobs" only support Azure storage. Simply suggesting you slight amend your answer to clarify this. – Emilio Aug 13 '14 at 20:38
  • Also, here https://stackoverflow.com/questions/21758043/azure-web-job-how-to-connect-to-an-azure-ms-sql-database is a case in point where the OP says "This SO thread indicates that WebJobs does not support SQL database..." He is responding that way because in an answer to that question Victor says "Unfortunately the WebJobs SDK does not support SQL databases. It only supports Azure Storage (blobs, queues and tables).", which, as is stated similarly to your answer here, confused the OP. – Emilio Aug 13 '14 at 20:45
  • I understand and accept your comment, it is quite confusing, and I'm open to tweaking my answer, just the last comment about only having a triggering part was not true, the first line should summarize it *To use the Azure Websites WebJobs feature you don't have to use the WebJobs SDK* – Amit Apple Aug 13 '14 at 22:46
1

WebJobs SDK is not only triggers (storage and service bus). Even if you don't use the triggers, the WebJobs dashboard is very valuable - you get some powerful diagnostics and you can debug your production systems better.

Victor Hurdugaci
  • 28,177
  • 5
  • 87
  • 103