Use durable function with blobstorage trigger and i get an error

Kamil 1 Reputation point
2020-08-05T13:35:28.903+00:00

Hello i've tried to use durable function with blobstorage trigger and i get an error.... what do i do wrong?
15817-image.png

15818-image.png

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
{count} votes

2 answers

Sort by: Most helpful
  1. JayaC-MSFT 5,606 Reputation points
    2020-08-06T16:07:52.477+00:00

    @Kamil Logically you can have one trigger type per function.
    In this case if your function is triggered from blob action then you can consider adding an additional parameter [OrchestrationClient] DurableOrchestrationClient orchestrationClient which gives you the ability to start new orchestrations to further orchestrate how your function will be executed
    and deligate the work to the activity functions. You may want to look into the the durable function patterns https://learn.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-overview?tabs=csharp#application-patterns for your requirement.

    https://learn.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-instance-management?tabs=csharp#start-instances

    This is how you can set up Orchestration :https://learn.microsoft.com/en-us/sandbox/functions-recipes/durable-setup

    https://pacodelacruzag.wordpress.com/2018/04/17/azure-durable-functions-approval-workflow-with-sendgrid/ - explains the steps to implement blobtrigger with Durabale function.

    Suggestion: If you are working with small blob files, then you can go ahead with this approach, otherwise, ideally, you should use Event Grid trigger which starts the orchestration. Then in the orchestration, you can use an input binding to fetch the blob ( depending on the requirement), get the blob in an activity function

    Please let me know if this helps and answers your query.

    4 people found this answer helpful.
    0 comments No comments

  2. Aakash Sharma 6 Reputation points
    2020-08-09T15:23:58.453+00:00

    @Kamil You need to have two functions in this case - One durable function (orchestrator) itself, and second the Blob trigger. The purpose of the blob trigger would be to trigger running the durable function.

    For example, create blob trigger as below and not OrchestrationClient in the argument, rather than OrchestrationTrigger. The OrchestrationTrigger would be used as a trigger for your durable function.

    BlobTrigger

    [FunctionName("StartOrchestratorBlobTrigger")]  
            public async Task StartOrchestratorBlobTrigger(  
                [BlobTrigger("sample-workitems/{name}", Connection = "CloudSightStorage")] Stream myBlob,  
                string name,  
                [OrchestrationClient] DurableOrchestrationClient durableOrchestrationClient,  
                ILogger log)  
            {  
                // get your blob content, and desrialize if you need and pass it orchestrator instead of stream as below  
                await durableOrchestrationClient.StartNewAsync("YourNewDurableFunction", myBlob);  
            }  
    

    DurableFunction

       [FunctionName("YourNewDurableFunction")]  
        public async Task YourNewDurableFunction(  
            [OrchestrationTrigger] DurableOrchestrationContextBase orchestrationContext,  
            ILogger logger)  
       {  
           // Call activity functions here.  
       }  
    
    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.