0

The following code will create a file in a container on my Azure Storage Account.

public static async Task<IActionResult> Run(HttpRequest req, ILogger log, Stream outputBlob)
{  
   log.LogInformation("C# HTTP trigger function processed a request.");
   using (StreamReader streamReader = new StreamReader(req.Body)) {

        string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
        byte[] bytes = Encoding.ASCII.GetBytes(requestBody);
        await outputBlob.WriteAsync(bytes);
        return (ActionResult) new OkObjectResult("ok");

     }
}

enter image description here

The outputBlob is pointing to the StorageAccount. My question is: How do I add an .json extension to the filename?

K N
  • 279
  • 5
  • 22
  • Are you using AzureBlobStorage Class? You can try the method described here https://stackoverflow.com/questions/47198544/write-stream-async-to-azure-blobstorage – Anupam Chand Jul 13 '21 at 10:17
  • Can you edit your question share your complete code? How are you creating `outputBlob` in your code. – Gaurav Mantri Jul 13 '21 at 10:20
  • Have you seen https://stackoverflow.com/a/10040559/2490286 ? Besides that you need to physically name your file with a .json extension – misha130 Jul 13 '21 at 10:57
  • I hve updated the question, maybe you have some pointers? – K N Jul 14 '21 at 06:47

0 Answers0