Reputation: 60871
Why is my blob being created without any content?
I have an output binding set to create a blob in the following:
public static class OnSchedulingToMMMQueueTriggered
{
[FunctionName("OnSchedulingToMMMQueueTriggered")]
public static void Run(
[QueueTrigger("httpqueue", Connection = "OnSchedulingToMMMQueueTriggered:SourceQueueConnection")] MyPayload myQueueItem,
[Blob("processed/{Payload}", FileAccess.Write, Connection = "OnSchedulingToMMMQueueTriggered:ProcessedPayloadsConnectionString")] Stream processedPayload,
ILogger log)
{
log.LogInformation($"C# Queue trigger function processed: {myQueueItem.Payload}");
processedPayload = StreamGenerator.GenerateStreamFromString(myQueueItem.Payload);
}
}
It creates a blob, and assigns it the correct naming with processed/{Payload}
; however, when I check to see what's inside the blob, it is empty!
I am assuming that this is not working:
processedPayload = StreamGenerator.GenerateStreamFromString(myQueueItem.Payload);
The example I am following is this one, from here:
[FunctionName("ResizeImage")]
public static void Run(
[BlobTrigger("sample-images/{name}")] Stream image,
[Blob("sample-images-sm/{name}", FileAccess.Write)] Stream imageSmall, //output blob
[Blob("sample-images-md/{name}", FileAccess.Write)] Stream imageMedium)
{
//your code here
}
Why is the blob being created as empty?
Here's my implementation of the StreamGenerator
:
public static class StreamGenerator
{
public static Stream GenerateStreamFromString(string s)
{
var stream = new MemoryStream();
var writer = new StreamWriter(stream);
writer.Write(s);
writer.Flush();
stream.Position = 0;
return stream;
}
}
Upvotes: 0
Views: 349
Reputation: 8156
seems your code assign generated stream to a local var processedPayload
You may want
StreamGenerator.GenerateStreamFromString(myQueueItem.Payload).CopyTo(processedPayload)
Upvotes: 1