0
votes

I am using the Azure Storage File Shares client library for .NET in order to save files in the cloud, read them and so on. I got a file saved in the storage which is supposed to be updated after every time I'm doing a specific action in my code.

The way I'm doing it now is by downloading the file from the storage using

ShareFileDownloadInfo download = file.Download();

And then I edit the file locally and uploading it back to the storage.

The problem is that the file can be updated frequently which means lots of downloads and uploads of the file which increases in size.

Is there a better way of editing a file on Azure storage? Maybe some way to edit the file directly in the storage without the need to download it before editing?

1
what do you have in mind? File storage is just... a storage. To do anything with the file, you need to fetch (=download) it first. If you only need to add data to an existing file Append Blobs might be an option but thats pretty different than File Sharessilent
Maybe there's an option to edit it somehow directly on the storage without downloading it?Yonatan Nir

1 Answers

0
votes

Downloading and uploading the file is the correct way to make edits with the way you currently handling the data. If you are finding yourself doing this often, there are some strategies you could use to reduce traffic:

  1. If you are the only one editing the file you could cache a copy of it locally and upload the updates to that copy instead of downloading it each time.
  2. Cache pending updates and only update the file at regular intervals instead of with each change.
  3. Break the single file up into multiple time-boxed files, say one per hour. This wouldn't help with frequency but it can with size.

FYI, when pushing logs to storage, many Azure services use a combination of #2 and #3 to minimize traffic.