Read a text file of webapp from webjobs in azure - 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.

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.

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.

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

Related

Best way to run .exe file in Azure?

I have an .exe application that outputs a file into the folder path you give as an input. The end goal is to get the output file into blob storage.
I have considered azure functions but not sure if it is possible to provide it with a folder path ... anybody have any ideas?
If you want to run an .exe application in Azure, you can use Azure Functions. You can use an Azure Function to trigger the .exe application to run, and then use another Azure Function to get the output file from the application and store it in blob storage.
You should be able to accomplish your task in Azure Functions, but it does not run an exe. For that, you need Azure Batch to execute custom activity.

Backup of azure storage account file share

I have quite a few shared files in an azure file share, what is the best backup method for these?
This is in case a user deletes a file and I need to recover, I understand that the files on azure storage are written across multiple disks
There is no real answer to this, you can use any backup solution\technic you desire.
As for the Azure side, Azure does provide a way to do this, but for blobs only. https://blogs.msdn.microsoft.com/windowsazurestorage/2012/06/12/introducing-asynchronous-cross-account-copy-blob/
edit: As Gaurav pointed out, you could async copy the Azure Files.
https://learn.microsoft.com/en-us/azure/storage/storage-use-azcopy#file-copy

Upload and use web folder on Windows Azure

We already allow our users to upload files through the app to the Azure Blob Storage, and then view them inside the app.
What we need now is to allow the upload of an entire folder containing web files (html, js, css, images...) maintaining the folder structure that it has and then be able to run these files in the browser. The link references between the files must be maintained also so it can work.
What will be the correct way to do this?
Is it possible through Blob Storage or do we need to upload the folder and its contents directly to the file system?
Thanks!
Note the Azure Blob storage doesn't have a concept of a "folder". The closest you would get would be to name a file "foldername/filename.ext". How you populate blob storage in this fashion would depend on how you allow a user to upload all their files. Perhaps as a zip file or through some form of ajax-based file upload UI on a web page... not sure. Ultimately you can't build folders but should be able to replicate the behaviours of one.

How to write in an Azure Website from a Webjob?

I know how to write into the storage, but how can I write in a web site from a web job? I want to use a webjob to insert some stuff in an azure database and images in a web site. I know that my webjob is:
uploaded in the dir /App_Data/jobs/triggered/myjob
but I can't write the a dir /images
The your webjob has access to an environment variable called %HOME% using it like this %HOME%\site\wwwroot points you to the root of your site( dir / in your terminology). doing this
var imageDir = Environment.ExpandEnvironmentVariables(#"%HOME%\site\wwwroot\images");
will give you the full path to your images folder in imageDir. Your webjob can write anything there.
Unfortunately, the Azure WebJobs SDK does not support binding to databases or the file system. Only Azure Storage is supported out of the box.
However, you can manually create a connection to a database from a WebJob and perform DB operations.

Azure Blob - Multiple files into one zip file before downloading

I'm currenlty using Azure Blob to store files, and upload/download from ASP.Net Application hosted outside of Azure. (I do not have Web Role and Worker Role.)
Is it possible to zip multiple files into one zip file within Azure Blob before downloading?
Thanks in advance!
THe only way to achieve this would be to do it by using a WIndows Azure Compute Role in the cloud. You obviously wouldn't want to do it on your on-prem servers as you'd round-trip the files twice.
One approach you might consider would be to build a download 'client' in Silverlight. This could handle the communications to blob stgorage and pull down the blobs (maybe in parallel) and then create the zip client side for saving.
But the short answer is this is not possible using WIndows Azure storage alone.

Resources