Harshal Yelpale
Harshal Yelpale

Reputation: 535

Read a text file of webapp from webjobs in azure

I have a webapp and in webapp i have some text files uploaded in temp directory. Next, i also have a webjob to process these files but the problem is i'm not able to access these files from that webapp's temp directory.

Is there any way to achieve this?

Thanks in advance.

Upvotes: 1

Views: 1057

Answers (3)

David Ebbo
David Ebbo

Reputation: 43203

The main site and WebJobs don't share the same %TMP% dir, which is why this doesn't work. One option would be to create those files somewhere under d:\home, e.g. in d:\home\data\tmp`. Then you'll be able to access it from both.

Keep in mind that if you scale out, all the instances will be sharing the same folder, so you may need to name the folder after the instance ID if you don't want that.

Upvotes: 3

Thiago Custodio
Thiago Custodio

Reputation: 18387

I would complement Tiklu's answer. You can solve your problem easily with Azure Functions, which is the evolution of Azure WebJobs SDK. You just upload the text file to a blob and use Azure Functions with BlobStorageTrigger to read the content of the file.

here's a sample:

https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob

Upvotes: 2

Tiklu Ganguly
Tiklu Ganguly

Reputation: 357

The standard way of achieving this would be to put the text files in a blob storage and then read it via webjob. Because in Azure you cannot really guarantee that the temp folder would be shared between the web app and the webjob.

Upvotes: 5

Related Questions