.net 6 azure function time trigger 404 not found error - azure

First time with .NET 6 runtime on Azure and I get the following error.
The time trigger function is not fired and I can not run it manually from portal.
Also, I try the following documentation
https://learn.microsoft.com/en-us/azure/azure-functions/functions-manually-run-non-http
but i get 404 not found error again.
*Time trigger working from localhost
*Visual Studio 2022 v 17.2.3
"FUNCTIONS_WORKER_RUNTIME": "dotnet",

Every time I create Time Trigger Azure function for NCRONTAB expression I use the following site https://crontab.guru/every-minute
In this case (once every 4 hours) is not working. So the 404 error not found based on an incorrect expression.
The valid expression is "0 0 */4 * * *" and i was using "0 */4 * * *"
https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer?tabs=in-process&pivots=programming-language-csharp

Related

Azure Function App Not triggering TimerTrigger in Visual Studio Debug

I have Azure Function app that I was able to debug previously but now it would not trigger when I start it in Visual Studio debug mode. Function looks like this:
public static void RunDownloadTask([TimerTrigger("0 */30 * * * *")] TimerInfo timerInfo, TextWriter log)
{...}
When I started in debug in Visual studio I used to get output like the following, but now I only get the first two lines of message in console. The rest "The next 5 occurrences ..." does not show up, and the function never gets triggered. Has anyone experienced something like this and know how to fix it? Looks like the instances I deployed to Azure App Service continue to work, but I don't know why I can't run this in debug mode locally anymore.
Found the following functions:
ChaseFTPDownloader.Functions.RunDownloadTask
The next 5 occurrences of the schedule will be:
10/5/2020 4:30:00 PM
10/5/2020 5:00:00 PM
...
I can reproduce your problem:
This is the problem of the settings of the Visual Studio.
Solution:
Just right click your functionapp in VS and add this command to the properties of your project:
start --verbose
After that you will see the log like before:(this change is updated in recent months.)
I think your function should start. Why you don't see it triggered is because the cron expression of your timetrigger.(It has an interval of 30 minutes and will not trigger the first time.)
Please do a test and let me know whether this can help you.

How to configure azure webjob to run every 30 seconds

This should be quick - I know how to run .net webjobs down to every minute..
eg 0 0/1 * 1/1 * *
but I would like to run every 10 seconds!! I can find unix methods, but no azure webjobs / ,net examples..
To schedule a triggered WebJob you need to add a schedule property to the settings.job file. The value of the schedule is cron expression that has 6 fields to represent the schedule: {second} {minute} {hour} {day} {month} {day of the week}.
So you just add the following to a settings.job file if you want to run every 10 seconds.
{
"schedule": "*/10 * * * * *"
}
If your app runs continuous or scheduled WebJobs, enable Always On to ensure that the WebJobs run reliably. This feature is available only in the Basic, Standard, and Premium pricing tiers.
For more details, you could refer to this article.
the patterns seems to be like Cron schedule jobs
*/10 * * * *
https://crontab.guru

Function App Time trigger not working

I have a function App. type is Timetrigger. I have given the time trigger expression 0 0 * * * * , as my requirement it to run with 1 Hour interval. I have refereed the TimeTrigger Cheat Sheet
But Unfortunetly its triggering in each 5 min. Somehow it's not working. Help me regarding this.
target--> Run the function App in the interval of 1 Hour.
If you have changed your code, I suggest you could right click project>rebuild your project to try again. Or you could try to use expression like '0 0 */1 * * *'.
The result:
But not sure why its getting triggered 5 min while putting the code in Azure Portal.
The code in portal and Visual Studio is different. You could try to right click project>publish>choose Azure function service to publish your function to portal. Then check the schedule in function.json:
In Portal, you could also click '+' to create TimeTrigger in Azure function service directly:
I got a conclusion out of the Issue, Although you will update the Time trigger schedule in the Code level, this will not impact the Running schedule. What ever is there in the configuration ( go to Integrate tab of the function App & check the timer value). Code value changes not impacting the config values. Need to change the config values manually.
You can set the trigger time as a config value, something like this:
[FunctionName(nameof(TimerFunction))]
public static async Task Run(
[TimerTrigger("%schedule%")]
TimerInfo timerInfo,
TraceWriter log)
{}
and then define schedule in the Application Settings of your Function App in Azure portal:
schedule 0 */5 * * * * (in this case every five minutes)
I'm using crontab.guru for choosing triggering intervals

Azure Timer Function is running multiple times on trigger

I have a timer function that runs every 12 hours that refreshes an oAuth token. For some reason the function run over and over many times resulting in about 3500 calls every 12 hours. Not sure if it is relevant but I have implemented the function in c# in Visual Studio and deployed to azure. My function does have an output binding to a azure blob for writing the refreshed token information. I thought originally that the problem was because I implemented the function as Async but the problem persists despite removing async.
Cron expression is wrong. I was using * * */12 * * * instead of 0 0 */12 * * *

azure - scheduling a webjob

I've developed a webjob and while I've been testing it, I set it to be manually triggered. I'm happy with the functionality and now I want to set it to run every 30 minutes.
In the publish file (webjob-publish-settings.json) I set this "runMode": "Continuous" and I included a setings.job file with this setting
{
"schedule": "0 */30 * * * *"
}
I initially set it to 'copy if newer' and I uploaded the webjob. In the azure webjobs section I had a listing for this webjob, type = continuous and it showed the schedule setting.
I've had to make some amendments and upload again but now the status says 'Pending Restart' and the schedule info has gone. I changed the settings.job file to 'copy always' but the schedule still isn't showing.(just n/a)
how is this process supposed to work ?
** UPDATE
I still cant get this to work, in my main program file I have this
Task callTask = host.CallAsync(typeof(Functions).GetMethod("CreateQueueMessage"));
callTask.Wait();
I then have a webjob-publish-settings.json file with this
"runMode": "OnDemand"
and finally, a settings.job file with this
"schedule": "0 0,15,30,45 * * * *"
so I would expect it to run every 15 mins now, but it doesn't, the schedule doesn't even show up alongside the webjob
If your goal is to have a scheduled WebJob, you should not be deploying it as a Continuous WebJob, which is a very different thing. Continuous WebJobs are for cases where you have an executable that starts and never terminates. Triggered (and scheduled) WebJobs are used when you have an exe that starts, performs one task, and then terminates.
The schedule is completely ignored in continuous WebJobs.
The reason you're seeing your Continuous job run every minute is that the system keeps trying to restart it, since it expects it to never terminate.

Resources