Azure WebJob never ran. Why? - azure

Navigating to App Services in Azure, then navigating to WebJobs, I am able to add a new WebJob. I name it, upload a zip file with the necessary files, and under type, I select triggered instead of continuous. For Triggers, scheduled is selected.
For the CRON expression, I put 0 */5 * * * *. Sure enough, this WebJob runs every 5 minutes. I can check my WebJob Logs to see their status and that they're returned "successful".
However, when attempting to do the same process but with a different CRON expression, the WebJob never ran.
Yesterday, I uploaded the same exact zip file as above, but with 0 0 5 * * * as the CRON Expression (Set to run at 5AM every morning).
I checked this morning in my Microsoft Azure WebJobs Logs and under "Last Run Time", the WebJob says Never ran.
Why is this?
Will the WebJob not run if I'm not logged into Azure to make sure it runs? How can I guarantee this WebJob to be run?
Anyone else having this problem?

All times are UTC as already mentioned here by someone else. If you have something against UTC, you can alter the timezone by setting WEBSITE_TIME_ZONE application setting as detailed here.
Also make sure you have Always On enabled for the site that hosts the Webjob, otherwise the w3wp.exe process that is in charge of the crontab won't be around to kick off your job.
Azure Portal → Your Web App → Application Settings → Always On
For completness's sake, Kudu uses a 6-field cron expression. The 1st field represents seconds rather than minutes (which is the first field in classic crontab).
More here: https://github.com/projectkudu/kudu/wiki/Web-jobs#scheduling-a-triggered-webjob

Related

How can i fix the deployement error 'starter.cmd "D:\home\site\d ..."' was aborted

I am having this error while deploying my nodejs code to azure app service through CD linked to my azure repos repository :
"Command 'starter.cmd "D:\home\site\d ...' was aborted due to no
output nor CPU activity for 60 seconds. You can increase the
SCM_COMMAND_IDLE_TIMEOUT app setting (or WEBJOBS_IDLE_TIMEOUT if this
is a WebJob) if needed.\r\nstarter.cmd
"D:\home\site\deployments\tools\deploy.cmd""
Any ideas ? Thanks :)
By default, when your build process launches some command, it's allowed to run for up to 60 seconds without producing any output. If that is not long enough, you can make it longer, e.g. to make it 10 minutes:
SCM_COMMAND_IDLE_TIMEOUT=600
Note that on Azure, there is a general idle request timeout that will cause clients to get disconnected after 230 seconds. However, the command will still continue running server-side after that.
You can do this by going to Azure Portal > select your web app> under settings click Configure tab and add an New Application Settings SCM_COMMAND_IDLE_TIMEOUT to say 600
Agree to the solution that is shared by Sneha
my first solution would be increasing the "SCM_COMMAND_IDLE_TIMEOUT" to 600 in the app setting of the web app.
Alternatively, If expecting a CONTINUOUS webjob this isn't something that happens by default (Even though the webjob appears to run by the rules until timeout). This is something that has to be selected in the Visual Studio Publish properties as detailed here
Once continuous is selected and the webjob is published, this error goes away
If you are using vnet integration you need to remove WEBSITE_VNET_ROUTE_ALL=1 in application setting. The deployment will be successful. Without this setting, web app routes only RFC1918 traffic into the VNet.
This document covers more information about integration with virtual network

How come my Azure timer function app stops firing

I have an Azure timer function app that fires every five minutes
I have found this very hit and miss after deploying. It either starts firing or it doesn't. It if doesn't fire then no matter what I do I cannot seem to get it to fire.
I have tried restarting and refreshing the function in the portal
It is running on a S1 App service plan (that also has three other func apps on it)
My timer cron expression is * */5 * * *
I found a github issue relating the same.
There is an issue right now if you deploy timer based functions that
are disabled via app setting then change the app setting to enable
them. To work around until the fix is made you should click the
'refresh' button in the Azure portal after changing app settings used
for disabling functions.
I have found that Azure Timer trigger Functions will fail to fire unless you use the B1 or higher app service plan. They should work in the free or shared plans ( docs say so ) but mine keep failing. Hopefully Microsoft will address this at some point.
I ended up redeploying all the components in the resource group again and then it started to fire. It is even firing on the basic consumption plan now so not sure what happened

Make scheduled call on Azure with webjobs

I have a nodejs application deployed on Azure and I want to make a call to it let's say every friday.
Can I upload a .bat file to the webjob and tell it to call app.azurewebsites.net/test ?
Is it possible this way or is it more complex than this?
Thank you,
Mihai Dobrescu
Update:
If you just want to call the website from webjobs, it's possible. Otherwise, you can ignore my answer.
I'm not familiar with .bat, here is an link Azure WebJob calling a Web Page using Powershell. You can modify to .bat in the same way.
Please correct me if I misunderstand you.
If you just want to call the site url deployed in azure every Friday, you can just write some code to call the website(.bat / powershell / .net etc.) as webjobs, then set the schedule as per the Cron Expression(the site is broken now, please refer to this one).
If call every Friday at 9:00, the schedule like below:
0 0 9 * * Fri
When it comes to Azure WebJobs, it is actually a background app. It is not supposed to accept an incoming request just like that. However, it makes sense to post some data to a Azure queue/table record and have the WebJob or anything else read it to take suitable action. If you explain in more detail, I can help more.
Not to complicate stuff, but Azure functions also help a lot in scenarios like these.

how to perform background jobs in azure

I am new to azure.
I want to run some background process on schedule interval in azure.
for example i have sample web app that send test mail.how can I runthat on every 10 minutes in azure.
i read about webjobs and how can i schedule them. I tried also creating aconsole app and uploading .exe. it runs but gets filed.
I dont know how i can upload web app also as web job same as I did for exe??
or need to opt for another option like worker role..
I m totally new to it.. so please guys suggest what would be suitable for my requirement.
I will go through it .
EDIT:
Sending mail is not my requirement. i m just doing that to check is my web job running succesfully at scheduled time interval or not.
but as i m getting unexpected response i think i should write some other code like write textfile azure storage account at every minute..
as i m totaly new.. dont have any idea about that ..anyone can share me any good link or sample demo if you can.please.
Here are two ways to develop a web job.
First
Upload a zip file that contains your executable or script file as well as any supporting files needed to run the program or script. The supported executable or script file types are listed as below.
For example, if you want to use a console application as the web job, we can go to the [ApplicationSolutionFolder/bin] and compress the Release or Debug folder as an zip file(It's better to use Release folder), then upload this zip file to azure as the web job.
Second:
We can develop it via Visual Studio: Deploy a WebJobs project
Update:
As you want to run every 10 minutes, we can set the triggers as scheduled and set the CRON expressions as [0 */10 * * * *] when we upload our zip file.
More information about CRON expressions, we can refer to: CRON expressions

Azure web job stops running

I have a PowerShell script that runs every 5 minutes via the Web Job functionality of a Web App.
Along with the Powershell script I have a settings.job with the following config, which is what makes it tick rather than configuring it as part of the Web job setup:
{
"schedule": "0 */5 * * * *"
}
The job runs successfully each 5 mins for a few hours, but i notice each morning that is has stopped. I'm thinking maybe as a result of an IIS Recycle (?) the job is stopping and then I have to manually kick it off again.
How do I keep it always running?
From the documentation under "Create a scheduled WebJob using a CRON expression":
This technique is available to Web Apps running in Basic, Standard or Premium mode, and requires the Always On setting to be enabled on the app.
Can you check whether your Web App is using Always On?
You might try Azure Automation it can run PowerShell scripts and can be kicked off via a Schedule

Resources