79487929

Date: 2025-03-05 23:48:09
Score: 1
Natty:
Report link

Best way to solve your own problem....

Wait until the following day, think about it with a fresh brain, read some of the other references, try them out....

I found this: Append text to Blob in Azure And took the answer from https://stackoverflow.com/users/1715749/antonk which just worked :-)

Adjusted my code to...

   public  static String AppendTextToAzureBlob  ( String aText ) 
   {
     String lBlobName = $"appendblob_{DateTime.UtcNow:yyyyMMddHH}";

     try
     {
       byte[] byteArray = Encoding.UTF8.GetBytes(aText);

       using (MemoryStream stream = new MemoryStream(byteArray))
       {
         var blobServiceClient = new BlobServiceClient(GetConnectionString());
         var blobContainerClient = blobServiceClient.GetBlobContainerClient(_BlobContainerName);
         blobContainerClient.CreateIfNotExists();
         var appendBlob = blobContainerClient.GetAppendBlobClient(lBlobName);
         appendBlob.CreateIfNotExists();
         appendBlob.AppendBlock(stream);
       }
       return "OK";
     }
     catch (Exception ex)
     {
       return ex.Message;
     }
   }
Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: user3427399