2
votes

I'm confused about deployment webjobs to azure.

I'm using .net core, so I manaully publish my webjobs in my deploy.cmd file, for example like this:

call :ExecuteCmd dotnet publish "%DEPLOYMENT_SOURCE%\My.WebJobs\Mt.WebJobs.csproj" --output "%DEPLOYMENT_TEMP%\App_Data\Jobs\Continuous\MyWebJobs" --configuration Release

That then deploys the webjob to the deployment_temp folder. After that, KuduSync kicks in and syncs to DEPLOYMENT_TARGET which is d:\home\site\wwwroot I can see in there if I look, that there is a App_Data\Jobs\Continuous\MyWebJobs folder, and that ALL my files have been correctly deployed and sync-ed up to that folder.

However, when I run the webjob, it reports it's running from a totally different location (D:\local\Temp\jobs\continuous\MyCustomerIO\bp003r3f.h2g). And when I look in that folder, I see most of my deployed webjob files, but some JSON configuration files that are in App_Data... are missing from here.

So - why is my webjob running from here? And why are some of my deployed files missing?

1

1 Answers

4
votes

why is my webjob running from here?

The WebJob is copied to a temporary directory under %TEMP%\jobs\{job type}\{job name}\{random name} and will run from there. This option prevents the original WebJob binaries from being locked which might cause issues redeploying the WebJob.

The WebJob is run directly from the WebJob binaries directory. We call this option in place. This option can have the locking issue and should only be used when there is no risk of locking the file.

By default the first option is used (in place = false).You can explicitly configure this setting in your settings.job. e.g.

{ "is_in_place": true/false }

And why are some of my deployed files missing?

I tested and reproduced this situation too. But I did not find solution to solve this. I suggest that you could use Environment.GetEnvironmentVariable("WEBJOBS_ROOT_PATH"); to get the root path direcroty of webjob.

WEBJOBS_ROOT_PATH which is location of webjob files, you can specify an absolute path, or otherwise the value will be combined with the default root path:

D:/home/site/wwwroot/ + WEBJOBS_ROOT_PATH(relative) to get webjob_name, webjob_run_id and so on.

For more detail, you could read this article.