Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Append a Text File in an Azure Blob with a Azure Function

I've got a text file I need to append data to daily with a timer Azure Function. The text file is a comma separated file. I've created my CloudBlobClient and knew how to make my Shared Access Policy and Token. I just don't know how to use this to upload. I only know how to get an access URI from the tutorial I'm working with.

like image 487
A.Rowan Avatar asked Mar 08 '23 23:03

A.Rowan


1 Answers

I've got a text file I need to append data to daily with a timer Azure Function.

You can try to use append blob that is optimized for append operations. According to your description, you know how to get SAS URI, so you can use SAS URI to create a reference to an append blob, and append a file to an append blob, the following code is for your reference.

CloudAppendBlob appendBlob = new CloudAppendBlob(new Uri("https://{storage_account}.blob.core.windows.net/{your_container}/append-blob.log?st=2017-09-25T02%3A10%3A00Z&se=2017-09-27T02%3A10%3A00Z&sp=rwl&sv=2015-04-05&sr=b&sig=d0MENO44GjtBLf7L8U%2B%2F2nGwPAayjiVSSHaKJgEkmIs%3D"));


appendBlob.AppendFromFile("{filepath}\source.txt");
like image 194
Fei Han Avatar answered Mar 11 '23 06:03

Fei Han