14

I am creating a dot net console app that will run as an Azure webjob. It is scheduled to run once an hour.

I am wondering how I pass a parameter to the job when it is invoked?

yamspog
  • 17,114
  • 16
  • 59
  • 94
  • That sort of defeats the purpose of "once per hour"... Time-triggered job are supposed to have all the information available when they start and not require additional input. What parameters are you trying to pass? Can you give more details your scenario? – Victor Hurdugaci Apr 11 '15 at 16:32
  • 4
    @VictorHurdugaci I don't know how you came to the conclusion that it defeats the purpose of a scheduled job to pass parameters to it. It makes total sense in a number of situations to me. For example, we have a cleanup process, and passing the number of days to cleanup is completely valid in our situation. – julealgon Jul 02 '15 at 20:18
  • We have a similar requirement. A couple jobs that save summary data. The same webjob can handle per 15 min, per hour, etc but need to pass in a parameter so I don't have to manage a bunch of different web jobs that all have the same code. – lucuma Jan 20 '17 at 20:43

1 Answers1

21

Scheduled WebJobs are actually 2 separate resources:

  1. Triggered WebJob
  2. Azure Scheduler Job

To pass parameters to the WebJob you need to go to the scheduled job (in the management portal) and update the url that is used to invoke the triggered WebJob.

The REST API is described here: https://github.com/projectkudu/kudu/wiki/WebJobs-API#invoke-a-triggered-job

Basically you just need to add ?arguments={your arguments} to the end of the url.

These arguments are passed as command line arguments to your executable.

Amit Apple
  • 8,674
  • 36
  • 49
  • For post requests too? What about sending multipart/form-data? – Triynko Apr 05 '16 at 20:43
  • 4
    Is this answer still valid? I do not see "Scheduled job" in the Management portal. They write a lot about putting settings.job file in App_Data/jobs/triggered/{JOB_NAME}/, but there are not examples how to include arguments there. I am not sure if that works. – Michal B. Jul 14 '16 at 14:43
  • this is still relevant, make sure to use the old portal – Amit Apple Jul 14 '16 at 18:59
  • It's relevant under the new portal too. Look for "Schedule Scheduler Collection". That is the container that holds Scheduler Jobs, which is the same as "scheduled job" referenced in this answer. – Brian Ball Nov 29 '16 at 22:26