2
votes

I have a web job that is supposed to be a triggered web job. I have it been deployed to azure fine and it is listed as a triggered webjob. However when I add things to the azure service bus that it has a function for. When i trigger it from the UI it works and will respond to my messages.

My host is configured like so

var config = new JobHostConfiguration
        {
            JobActivator = new MyActivator(container)
        };
        config.UseServiceBus();
        var host = new JobHost(config);
        host.RunAndBlock();

My Function looks something like this

public  void ProcessQueueMessage([ServiceBusTrigger("recipetest")] ProductName message, TextWriter log)
    {
        //code
    }

I have been looking for a while now but all google searches have given me back continuous web jobs with function triggers. Can anyone tell me how to get the web job to wake up and handle messages. I have found most other answers talk about always on but triggered jobs should work without always on.

2
Yeah you need a continuous job with "always on" - Thomas

2 Answers

4
votes

In my opinion, the differences between continuous webJob and trigger webjob is as below:

Continuous webJob: Always run a backend exe in the web application.

In webjob SDK ServiceBusTrigger scenarios, even though your individual functions are 'triggered', the WebJob as a while runs continuously (i.e. your exe keeps running and does its own internal triggering).

Triggered webjob: Triggered by schedule or manually.

Notice: Webjobs are all run by the web app's process and web apps are unloaded if they are idle for some period of time. This lets the system conserve resources.

So both Continuous and Triggered (scheduled CRON) webjobs require 'Always on'.

2
votes

To use ServiceBusTrigger, your WebJob has to be continuous.

To add a little more detail, the ServiceBusTriggerAttribute actually does poll the Message Queue that it monitors using a backoff if no messages are found. So you can see that messages added to the queue do not "wake up" a WebJob and tell it to do something - instead the ServiceBusTriggerAttribute polls and will find when new messages are waiting to be processed. This is why the WebJob can't be Triggered if you're using ServiceBusTriggerAttribute.