22 July 2022 Azure, AppService, WebJob Robert Muehsig

We are using WebJobs in our Azure App Service deployment and they are pretty “easy” for the most part. Just register a WebJobs or deploy your .exe/.bat/.ps1/... under the \site\wwwroot\app_data\Jobs\triggered folder and it should execute as described in the settings.job.

x

If you put any executable in this WebJob folder, it will be executed as planned.

Problem: Parameters

If you have a my-job.exe, then this will be invoked from the runtime. But what if you need to invoke it with a parameter like my-job.exe -param "test"?

Solution: run.cmd

The WebJob environment is “greedy” and will search for a run.cmd (or run.exe) and if this is found, it will be executed and it doesn’t matter if you have any other .exe files there. Stick to the run.cmd and use this to invoke your actual executable like this:

echo "Invoke my-job.exe with parameters - Start"

..\MyJob\my-job.exe -param "test"

echo "Invoke my-job.exe with parameters - Done"

Be aware, that the path must “match”. We use this run.cmd-approach in combination with the is_in_place-option (see here) and are happy with the results).

A more detailed explanation can be found here.

Hope this helps!


Written by Robert Muehsig

Software Developer - from Saxony, Germany - working on this product. Microsoft MVP & Web Geek.
Other Projects: KnowYourStack.com | ExpensiveMeeting | EinKofferVollerReisen.de