简体   繁体   中英

Editing a file in Azure storage

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM