-1

I finally reproduced this issue with the code below. I am simply triggering a durable function with a blob trigger, and in one of the activity functions I read the blob. BUT... when I read the blob I get an error that the blob doesn't exist.

Can someone explain what I am doing wrong here?

Code:

[FunctionName("BlobTrigger")]
public static async void Trigger(
[BlobTrigger("incoming-blob/{filename}", Connection = "")]Stream myBlob,
[OrchestrationClient]DurableOrchestrationClient starter,
string filename,
ILogger log)
{
    var instanceId = await starter.StartNewAsync("Orchestrator", filename);
}

[FunctionName("Orchestrator")]
public static async Task RunOrchestrator(
    [OrchestrationTrigger] DurableOrchestrationContext context)
{
    var filename = context.GetInput<string>();
    await context.CallActivityAsync("Read_Blob", filename);
}

[FunctionName("Read_Blob")]
public static async Task Activity(
    [ActivityTrigger] string filename,
    [Blob("incoming-blob")] CloudBlobContainer container,
    ILogger log)
{
    var stream = new MemoryStream();
    var blob = container.GetBlockBlobReference(filename);
    await blob.DownloadToStreamAsync(stream);
    //EXCEPTION THROWN AT ABOVE LINE.
    stream.Dispose();
}
KickinMhl
  • 1,218
  • 3
  • 14
  • 32
  • By the way... this is obviously a simplification of what we are working on. The answer lies in using the blobContainer binding instead of binding directly to the blob content , or Stream. Even so, this should work. It is crazy that a blob trigger could fire when a file is not accessible. – KickinMhl Jun 07 '19 at 19:38
  • should it be `var blob = container.GetBlockBlobReference(filename);` rather than `var blob = container.GetBlockBlobReference("filename");` or is it just a typo ? – Thomas Jun 08 '19 at 08:57
  • Last comment: you should use EventGridTrigger rather than BlobTrigger: https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-event-overview. – Thomas Jun 08 '19 at 08:58
  • Yes just a typo – KickinMhl Jun 09 '19 at 14:10
  • Thomas... I spent the morning understanding the EventTrigger, and can certainly use that instead, however, isn't a BlobTrigger just a filtered EventTrigger? What makes you say that would be a better option? – KickinMhl Jun 10 '19 at 15:42
  • Over the weekend we found that this is not specific to Blob Triggers, it occurs accessing a recently created Blob as well, outside the context of a trigger. – KickinMhl Jun 10 '19 at 15:44
  • Based on new information over the weekend, I believe this is more of a Blob Storage question/issue, and not a Durable function/ BlobTrigger issue. Thinking this should be deleted. – KickinMhl Jun 10 '19 at 17:22

1 Answers1

0

Looks like you are trying container.GetBlockBlobReference("filename") rather than container.GetBlockBlobReference(filename) using the passed in parameter [ActivityTrigger] string filename

Chris
  • 3,113
  • 5
  • 24
  • 46
  • @KickinMhl and you still get an exception? – Chris Jun 09 '19 at 14:16
  • Not often... especially in this basic code example, but, when there is a bunch of traffic, it seems to degrade and then we get exceptions. Right now, for instance, this works fine. But during the day when we were doing some minor load testing and having troubles, I deployed this code and was having the same issue. – KickinMhl Jun 10 '19 at 13:50