Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal WebJob Scheduler: settings.job vs. webjobs-publish-settings.json #1601

Closed
robertmuehsig opened this issue Jun 26, 2015 · 6 comments
Closed

Comments

@robertmuehsig
Copy link

I tried to use the new internal WebJob Scheduler for my side project. I deleted the old webjob and the old scheduler via the Azure Portal. My scenario is simple: Building a small worker, that runs every hour. I use GitHub and I didn't want to use heavy tooling to change the schedule. It would be awesome if I could just change something in the github repo and the schedule is changed - so the new internal webjob scheduler seems perfect.

I added a new settings.job file to my console app. I edited the corresponding webjobs-list.json published it to GitHub which should hopefully trigger the Website/Webjob deployment. But it failed with a MSBuild Error "The target ResolveWebJobFiles does not exist in the project". I added the WebJobs-Publishing NuGet package, but this didn't resolve the error. I needed to add the webjob-publish-settings.json file like this (Code-Inside/Sloader@f6a0e66).

Here is the first question: Do I really need this file and if yes which "runMode" should I use for the internal scheduler? The scheduled runMode seems wrong, because I configure the scheduling now via the "settings.job" file. Or is this currently only needed because of an issue with your internal build scripts and this file must be in the project, otherwise "ResolveWebJobFiles" will fail?

So, with the "OnDemand" webjob-publish-settings.json, the correct webjobs-list.json and the settings.job the Website and the WebJob deployment was ok.

But it seems, that my webjob is not triggered:

[{"latest_run":null,"history_url":"https://sloader.scm.azurewebsites.net/api/triggeredwebjobs/Sloader-Sample-WebJobHost/history","scheduler_logs_url":"https://sloader.scm.azurewebsites.net/vfs/data/jobs/triggered/Sloader-Sample-WebJobHost/job_scheduler.log","name":"Sloader-Sample-WebJobHost","run_command":"Sloader.Sample.WebJobHost.exe","url":"https://sloader.scm.azurewebsites.net/api/triggeredwebjobs/Sloader-Sample-WebJobHost","extra_info_url":"https://sloader.scm.azurewebsites.net/azurejobs/#/jobs/triggered/Sloader-Sample-WebJobHost","type":"triggered","error":null,"using_sdk":false,"settings":{"schedule":"5 * * * *"}}]

The main question is: It seems that my webjob is not running as expected. Is my NCron Syntax wrong or do I miss something?

The actual WebJob:
https://github.com/Code-Inside/Sloader/tree/master/src/Sloader.Sample.WebJobHost

The hosting Website:
https://github.com/Code-Inside/Sloader/tree/master/src/Sloader.Web

I created this gist with all important settings files:
https://gist.github.com/robertmuehsig/a925d5ea4d76f8a2b682

@amitapl
Copy link
Contributor

amitapl commented Jun 26, 2015

The best place to start with scheduler issues is by going to the scheduler log at https://sloader.scm.azurewebsites.net/vfs/data/jobs/triggered/Sloader-Sample-WebJobHost/job_scheduler.log

Your schedule consist of 5 fields and it should be 6 so this is probably the issue.

The webjob*.json files you mention are part of the VS tooling, they are used by msbuild to build the webjob into the right place so they should be part of your repo.

@robertmuehsig
Copy link
Author

Ah, ok... the issue was the wrong syntax. So, the webjob_.json files are only for the build and the VS tooling, but the internal scheduler will just consume the settings.job file, right? The content of thethe webjob_.json files are not important for the scheduler and it doesn't matter if the runMode is on "ondemand" or anything else, correct?

@robertmuehsig
Copy link
Author

Ah, I found the source for the "wrong" cron expression. I followed the link in your blogpost to this side, which has only 5 components https://code.google.com/p/ncrontab/wiki/CrontabExamples
I found another generator, which will output 7 components (http://www.cronmaker.com/) - at least for NCron the generated cron expressions are invalid.

Edit: NCron seems to be not very compatible with other cron expression implementations
[06/26/2015 22:06:05 > 5b2940: SYS ERR ] Failed to parse schedule "0 0 0/1 * * ?". Error: '?' is not a valid [DayOfWeek] crontab field expression.
Which should be "ok" http://stackoverflow.com/questions/7683445/quartzs-crontrigger-for-every-two-hours

@robertmuehsig
Copy link
Author

Mh... I used this expression in my settings.job file:
{"schedule": "0 0 0/1 * * *"}

And I see this in my log:
[06/26/2015 22:08:18 > 5b2940: SYS INFO] Scheduling WebJob with 0 0 0 * * * next schedule expected in 01:51:41.1751196

What does expected in mean? My goal was to get the webjob running once per hour. Is the next run scheduled to a specific time (01:51.41 pm/am?) or in around 2 hours?
(Edit: I think I found the correct syntax: 0 0 * * * *)

Besides the syntax issue: This feature is awesome - just change some values in the GitHub repo and maybe you found the correct syntax ;)

@xoxoxexe
Copy link

Important to know:
[08/27/2015 14:05:50 > c58371: SYS INFO] 'Basic' tier website doesn`t support scheduled WebJob.

@davidebbo
Copy link
Member

Correct, the feature requires the site to be in Standard mode.

Closing this as it seems all issues have been figured out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants