2
votes

I'm moving from hosting instances of my app from multiple VMs, to multiple WebApps in Azure. I also have a batch tool that I run at various times on schedules to do different jobs. The particular job it does is controlled by a command line parameter, which is easy to do using Windows Task Scheduling.

There doesn't seem to be a way to specify parameters when running a WebJob, but I did find the following SO article that suggests using a Powershell script containing the parameters:

Command Line Arguments to Azure Webjobs

Excellent solution that would solve my problem. However, when uploading a zip containing my app, associated dlls and a powershell file as a WebJob, there doesn't seem to be a way to specify that I want the powershell file to be used as the WebJob, and the exe is used instead.

2

2 Answers

9
votes

WebJobs uses the following logic to decide which file is the script to run within the job's directory:

Per file type we look first for a file named: run.{file type extension} (for example run.cmd or run.exe. If it doesn't exists for all file types, we'll then look for the first file with a supported file type extension. The order of file types extension used is: .cmd, .bat, .exe, .ps1, .sh, .php, .py, .js.

The recommended script file to have in your job directory is: run.cmd.

Note: We'll only look for a script under the root directory of that job (not under sub directories of it).

Note: make sure .bat/.cmd files don't include the UTF-8 BOM (inserted by some editors such as Visual Studio by default), which can break things!

From: https://github.com/projectkudu/kudu/wiki/Web-jobs

8
votes

Name the running script as run.{extension} in your case run.ps1.

For more comprehensive description of how the script is chosen read https://github.com/projectkudu/kudu/wiki/Web-jobs