Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Web Job writes files in a website's directory

I attached a Web Job to my Azure website. The webjob prepares a file and I want to save it on a proper folder in the website.

Environment.CurrentDirectory run on the script returns a path under a Temp directory: Temp\jobs\triggered\WEBJOBNAME\q0uwrohv.x5e

I tried to go down on the directory tree:

string path = Path.Combine(Environment.CurrentDirectory, @"..\..\..\..\..\Data")

But it doesn't work:

C:\DWASFiles\Sites\WEBSITENAME\Temp\jobs\triggered\WEBJOBNAME\q0uwrohv.x5e\..\..\..\..\..\Data

How to make and save files from WebJob to a particular path?

I don't want to use blob store.

like image 759
Miroslav Popov Avatar asked Jun 11 '14 06:06

Miroslav Popov


People also ask

What is Azure web job storage?

An Azure storage account provides resources for storing queue and blob data in the cloud. It's also used by the WebJobs SDK to store logging data for the dashboard. Refer to the getting started guide and documentation for further information.

What is the limit of web jobs that can be deployed to the Azure App Service?

The default is 50.

How do I publish my Azure WebJobs?

In Solution Explorer, right-click the project and select Publish. In the Publish dialog box, select Azure for Target, and then select Next. Select Azure WebJobs for Specific target, and then select Next. Above App Service instances select the plus (+) button to Create a new Azure WebJob.

How do I check my Azure web job log?

Click on the WebJob that you want to monitor and then click on logs: This will open a new window and you will need to login with the same credentials that you use on the Azure Portal. You will be able to monitor the WebJobs from the dashboard.


2 Answers

The path for the root of your Azure Web Site is (usually) d:\home\site\wwwroot. d:\home is also stored in an environment setting called %HOME%.

To get more insight on the different paths you can use on your site go to: https://{sitename}.scm.azurewebsites.net, there' you'll have the Debug Console where you can browse through your site and Environment to see all the environment variables you can use.

Your WebJob will have access to the same paths/environment as your Web Site.

For more information on this administration site go to: http://azure.microsoft.com/blog/2014/03/28/windows-azure-websites-online-tools-you-should-know-about-2/

like image 173
Amit Apple Avatar answered Sep 24 '22 23:09

Amit Apple


try the following instead of putting a file location in the value parameter just put this as I show you here

you can do it in the app.config file

add key="app:TempFolderPath" value="~/temp/"/
add key="app:TempReportDirectory" value="~/temp/"/

the web job will automatically put in this location of

D:\local\Temp\jobs\continuous\ImporterWebJob\yex3ad1c.3wo\~\temp\...your file...

I hope this will not give you any errors.

like image 36
David Greenfeld Avatar answered Sep 24 '22 23:09

David Greenfeld