Reputation: 187
I need help on writing durable function with blob trigger can any one help on this.
I have already created a Blob Trigger function that will process any new file comes into the blob, now i need to migrate the blob trigger function to durable function and i don't see any option for blob trigger in durable function can any one guide me ?
Upvotes: 4
Views: 3373
Reputation: 678
You can just (after adding DurableFunctions to your Function App) extend the signature of your blob triggered function by an additional parameter [OrchestrationClient] DurableOrchestrationClient orchestrationClient
which gives you the ability to start new orchestrations.
[FunctionName("TriggeredByBlob")]
public static async void Run([BlobTrigger("container/{blobName}", Connection = "Blob:StorageConnection")]Stream requestBlob, string blobName, [OrchestrationClient] DurableOrchestrationClient orchestrationClient)
{
// ... you code goes here
string instanceId = await orchestrationClient.StartNewAsync("OrchestrationThatProccesesBlob", blobName);
// ... you code goes here
}
There is a sample from Paco de la Cruz here https://pacodelacruzag.wordpress.com/2018/04/17/azure-durable-functions-approval-workflow-with-sendgrid/ which shows some more details on how to do it.
Upvotes: 7