Error binding Blob to IAsyncCollector when binding to output blob in Async method

后端 未结 2 698
野趣味
野趣味 2021-01-15 03:20

I\'m trying to bind to a blob output in an Async method following this post: How can I bind output values to my async Azure Function?

I have multipl

2条回答
  •  离开以前
    2021-01-15 03:42

    You can use the Blob-Binding.

    I preferred this way, because I'm able to specify the ContentType.

     [FunctionName(nameof(Store))]
        public static async Task Store(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req,
            [Blob(
                "firstcontainer",
                FileAccess.Read,
                Connection = "blobConnection")] CloudBlobContainer blobContainer,
            ILogger log)
        {
            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
    
            string filename = "nextlevel/body.json";
    
            CloudBlockBlob blob = blobContainer.GetBlockBlobReference($"{filename}");
            blob.Properties.ContentType = "application/json";
            await blob.UploadTextAsync(requestBody);
    
            return (ActionResult)new OkResult();
        }
    

提交回复
热议问题