We have a WebJob in our Azure website that was supposed to listen to some messages on Azure Service Bus (ASB), so based on that we were expecting to run a process continuously so that it can listen to bus messages and process them as soon as they arrive. so with this background we chose “Run continuously” as WebJobs’s schedule at deployment time.
After some time, it appears that the WebJob does not work! and as usual we checked the Azure portal in that environment and checked the status of the job and noticed that it is running!
But the observation was, as soon as we open the WebJob tab in the azure portal we could see that it says “Web Job Starting” and after a few seconds it says “Web job Running”!
Any ideas about this behaviour and how to fix it?
There is a setting in the Configure tab called “ALWAYS ON“ which it has a very bold message on top of it that says “Should be turned on if you have a job that runs continuously”.
Here is how this setting looks like:
I also have a blog post about this issue:
https://koukia.ca/microsoft-windows-azure-webjobs-and-how-to-keep-them-awake-16283c28f19f#.nentaowwo
Related
I have an Azure WebJob that I created from the WebJobSDK, Service Bus monitor. Basically the WebJob continually monitors a Service Bus, processes the message, and continues looking for new messages. When I debug (F5) the application locally, the process works perfectly. It basically grabs the message from the Bus, transposes it into an XML file, copies that file to an Azure BLOB container, and then call Azure SQL to insert a control row.
My problem is that when I publish the WebJob, I have an error that I don't know how to debug. I can look at the Service Bus messages and see that the process is peeking the message, failing, doing that 9 more times, and then the messages goes into the dead message queue. That is expected when a message is peeked 10 times and never completed (I left this defaulted to 10), so I know my process is running but failing abnormally.
I have Try/Catches around all of my code. What do I need to place within the Catch to have something surfaced in the Azure Portal so I can debug what is wrong? I actually have a call in the catch handler that reads the exception.InnerException and attempts to write it to a DB table, but surprisingly, that never happens.
I appreciate any insight. Thanks a lot...
You can do this as follows:
In VS, go to Cloud Explorer (make sure you have the latest Azure tools)
Find your Web App under App Service
Under it, go under WebJobs and find your Continuous WebJob
Right Click it and choose Attach Debugger
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.
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'.
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.
When I read the documentation for azure WebJobs, it found below statement For Continuous WebJobs to run reliably and on all instances refer to image below
My WebJob workflow:
Need to prepare the report for the newly created user in my application at 12 AM EST and send me the report in Email in daily occurrence.This time is changeable by UI so I need to run job continuously to find and run schedule at selected time
My Question
If WebJob runs all instance say two instances in running now for my web app.
Will I receive two email such that WebJob in each instance prepare the report and send to me?
Will get only one email irrespective of how many WebJobs are running?
A Continuous WebJob by default runs on all instances of your App Service Plan.
Whether your WebJob will run twice depends on how you implemented it. A Service Bus Queue listening WebJob will only run a queue message once, no matter how many instances (though if it fails, it'll run more than once).
If you wish, you can also make the WebJob run on a single instance by including a settings.job file in your WebJob with the following content:
{
"is_singleton": true
}
I have a Azure Scheduled Web Job on Azure WebApp. Inside web job, it downloads the excel file from azure blob and read (25 - 30 k records in a file), then it iterate through loop to insert's records in database. Now, when we schedule (Schedule time: 18 hrs) first time the job ran successfully and processed all records from file without any interruptions (between this time site was accessing). But, next time it fails (Aborted) without any reason (No one was accessed site. may be in idle state).
WebJob Abort Status
There is no any indications when i looked into logs. However, first schedule ran successfully and shows success status later all are in Aborted status, Why?
Success
Also done with below settings in webapp:
stopping_wait_time - 3600
WEBJOBS_IDLE_TIMEOUT - 3600
SCM_COMMAND_IDLE_TIMEOUT - 121
Per Azure's documentation,
Always On. By default, web apps are unloaded if they are idle for some
period of time. This lets the system conserve resources. In Basic or
Standard mode, you can enable Always On to keep the app loaded all the
time. If your app runs continuous web jobs, you should enable Always
On, or the web jobs may not run reliably.
So there is no promise from Azure Web Apps for your WebJob to continue running more than 20 minutes. If you need to rely on that you'll need to enable Always On. To enable it. See below.
In the Azure Portal, navigate to your App Services.
Click Application Settings in the SETTINGS menu.
Turn Always On to on, then click Save.
Here the picture:
If you are using the free tier of Azure, maybe this thread will help you: How can I keep my Azure WebJob running without "Always On".
I can successfully save my logs to Table store for a continuous WebJob, following these instructions:
https://azure.microsoft.com/en-us/documentation/articles/web-sites-enable-diagnostic-log/
However, if I make the WebJob scheduled (runs once every 5 mins), the logs do not show up in Table store. Is this a known limitation (and if so, why?), or does anyone know a way to make it work?
Note: I can see the logs in the Azure Portal, so I know the job runs correctly -- I just want to save these to a WADLogsTable.
Thanks!
Maybe your problem is related to this. Compress in a .zip the Release folder of your web job and then go to your azure webpage, click web jobs and add. Set your schedule in the menu that shows when you press add, you can change it later in your azure web job schedule menu.