Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command Line Arguments to Azure Webjobs

I'm in the process of migrating a couple of Jobs that were previously scheduled and run through Quartz.Net to Azure Webjobs.

Using Quartz.Net allowed me to have all the (very compact) Job Classes in the same project as the console program entry point initializing the scheduler.

Now I would like to retain that structure without having to create a discrete console application project for each and every web job.

Is there currently any way to configure a command line argument for continuous web-job that would allow to branch internally to the correct job depending on the command line argument?

like image 775
Oliver Weichhold Avatar asked Jul 21 '14 13:07

Oliver Weichhold


People also ask

How do I pass a parameter to Azure WebJob?

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. 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.

Is Azure WebJobs deprecated?

Azure WebJobs are deprecated, but still in use. They are being phased out in favor of Azure Functions. Azure Functions is a more up-to-date and feature rich service which offers a greater degree of flexibility and control.

What is the difference between Azure functions and WebJobs?

Summary. Azure Functions offers more developer productivity than Azure App Service WebJobs does. It also offers more options for programming languages, development environments, Azure service integration, and pricing. For most scenarios, it's the best choice.


1 Answers

In Azure WebJobs one way to do this is to create a script file for each WebJob with the command line arguments: MyApplication.exe arg1 arg2.

Another would be to select the method to run by the current WebJob name which you can get from the environment variable WEBJOBS_NAME.

For triggered WebJobs there is support for command line arguments (per run) in the API but it is still unsupported by the Azure portal: https://github.com/projectkudu/kudu/wiki/WebJobs-API#invoke-a-triggered-job.

like image 118
Amit Apple Avatar answered Sep 20 '22 11:09

Amit Apple