Mahdi Khardani
Mahdi Khardani

Reputation: 52

Download a file in C# console application that will be deployed as an Azure WebJob

I am creating a console app that downloads and crops image files from URLs, I would like the images to be stored within a folder in the project (Image) and I am planning to deploy it as an Azure Web Job

but when I download it, I find it in C:.........\consoleapp\bin\debug folder

I have been able to download the file locally and get access to it, but I am sure it's not done the same way while on Azure.

This is the code I am using to download the image:

WebClient client = new WebClient();
Stream stream = client.OpenRead(imageUrl);
var bitmap = new Bitmap(stream);
stream.Flush();
stream.Close();

Upvotes: 0

Views: 886

Answers (1)

JEV
JEV

Reputation: 2504

When downloading files using the WebClient, I believe you can specify a folder that they are downloaded too.

var wc = new WebClient();
await wc.DownloadFileAsync (new Uri("something.org/image.jpg"),"C:\\Downloads\\dl_image.jpg");

If you are asking around how it would work on WebJob I suspect one of two things would happen. 1) It would be downloaded to the equivalent binary folder 2) It would not be downloaded due to a lack of permissions

Would you not instead want to bring the data into memory, perform your cropping operation, and then store the result in a Azue Blob instead?

Upvotes: 1

Related Questions