8
votes

I deployed a WebJob the suggested way using Visual Studio, right-click onto the console project, selecting "Publish as Azure Webjob" and going through the settings. I selected a scheduled plan what caused the file "webjob-publish-settings.json" to be created in the Properties-Folder with the following content:

{
  "$schema": "http://schemastore.org/schemas/json/webjob-publish-settings.json",
  "webJobName": "TestCredentials2",
  "startTime": "2016-04-05T01:00:00+01:00",
  "endTime": "2016-04-12T00:00:00+01:00",
  "jobRecurrenceFrequency": "Minute",
  "interval": 3,
  "runMode": "Scheduled"
}

While the deployment worked, the webjob is in the state "On Demand". The Webjob is run once when I start it manually from within the Azure Portal but does not restart ever automatically.

I also tried to add a "settings.job" to the root of my project (with the setting "Copy if newer"):

{ "schedule": "0 /5 * * * *" }

Still no difference in the behaviour, but also no error message.

1
The suggested approach is to use CRON expressions (azure.microsoft.com/en-us/documentation/articles/…). You questions asks about both at the same time, so it is likely to cause confusion between the two (it's really questions). If you have troubles getting the CRON expression to work, I suggest asking a question that focuses on that exclusively.David Ebbo
I added the second (settings.job) just because the first approach did not work in the hope that might work.Ole Albers
Understood, but that ends up sort of asking two questions since they work widely differently.David Ebbo
I solved this by using a contious webjob and using Threading.Timer. More a hack than a solution.Ole Albers
there is a timertrigger for webjob stackoverflow.com/questions/36218203/…Thomas

1 Answers

23
votes

It did work using the settings.job approach. The following things had to be done:

1. Create a settings.job with the content in the question
2. select Build Action "Content" for that file
3. Select "Copy if newer"
4. Delete the generated "Properties/webjob-publish-actions.json"
5. Re-Publish the Project, chose "On Demand" instead of a schedule plan 

this creates a new webjob-publish-actions.json:

{
      "$schema": "http://schemastore.org/schemas/json/webjob-publish-settings.json",
      "webJobName": "MyTimer",
      "startTime": null,
      "endTime": null,
      "jobRecurrenceFrequency": null,
      "interval": null,
      "runMode": "OnDemand"
    }

Done.