Deploying a WebJob with a static Content file

1k Views Asked by At

A WebJob running on Azure does not seem to drop the <Content> files (Copy if Newer) into the correct directory.

I get the following error:

System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\local\Temp\jobs\continuous\LongTasks\lprysn1r.tsv\Content\File.cshtml

And I try to access that file as such: File.ReadAllText("Content/File.cshtml");

When running locally, it works just fine.

Is there a way to get this static file dropped appropriately?

2

There are 2 best solutions below

0
On BEST ANSWER

After doing some tests, the convention is they do a shallow copy of the /bin/Release folder to App_Data/jobs/continuous/LongTasks/

Which means, if there are any folders, they are not being copied. Moving the "File.cshtml" to the root directory fixes this problem.

I know this is not fully related to the Azure WebJobs SDK, but this is happening on 6/22/2015 with version 1.0.0.

0
On

You should use WEBJOBS_PATH environment variable for currently running webjob.

var webjobPath = Environment.GetEnvironmentVariable("WEBJOBS_PATH");

if (string.IsNullOrWhiteSpace(webjobPath))
{
   // Handle dev environment
   webjobPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
}

This will return some path like D:\local\Temp\jobs\triggered\\xxeeeexxx.qzx\, which contains your content files and folders.