call Orchestrator Function

Gerald Rupp 130 Reputation points
2023-08-09T20:27:39.3566667+00:00

Hallo everybody,

I have a Blob-Trigger Azure Function in python. Inside that Function I am calling an orchestrator-Function. I have problems to initialize the client.

Hope you can help me :)

This is my code so far:

def main(myblob: func.InputStream):
    # Get the blob URI
    blob_uri = myblob.uri
    logging.warning(f"Triggered by = '{blob_uri}'")
    
    if blob_uri.endswith('.json')==True:
        # Create a DurableOrchestrationClient
        client = ??

        # Start the orchestrator function and pass the blob URI as input
        instance_id = client.start_new('OrchestratorRailster', None, blobUri=blob_uri)

        logging.warning(f"Started orchestration with ID = '{instance_id}'")
    else:
        logging.warning(f"no json-file was modified. No Action for: '{blob_uri}'")

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

Accepted answer
  1. navba-MSFT 27,550 Reputation points Microsoft Employee Moderator
    2023-08-10T02:34:16.3833333+00:00

    @Gerald Rupp Welcome to Microsoft Q&A Forum, Thank you for posting your query here!

    I understand that you are having trouble initializing the client to call an orchestrator function.

    Could you please test if the below sample helps ?

    Within _init_.py have the below code:

    import logging
    import azure.functions as func
    import azure.durable_functions as df
    
    async def main(myblob: func.InputStream, starter: str):
        logging.info("Python blob trigger function processed blob)  
    
        client = df.DurableOrchestrationClient(starter)
        instance_id = await client.start_new('YourNewDurableFunction')
    

    I hope you have already added the function.json as below:

      "scriptFile": "__init__.py",
      "bindings": [
        {
          "name": "myblob",
          "type": "blobTrigger",
          "direction": "in",
          "path": "ContainerName/{name}",
          "connection": "AZURE_STORAGE_CONNECTION_STRING"
        },
        {
          "name": "starter",
          "type": "durableClient",
          "direction": "in"
        }
      ]
    }
    

    I am also sharing a few useful articles if that helps: I am sharing a few useful articles related to similar ask:

    https://learn.microsoft.com/en-us/answers/questions/59760/use-durable-function-with-blobstorage-trigger-and

    https://stackoverflow.com/questions/53784657/durable-function-blob-trigger https://learn.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-instance-management?tabs=python https://stackoverflow.com/questions/72344826/using-python-blob-trigger-as-durable-client-in-azure

    Hope this helps.

    **
    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    1 person found this answer helpful.

0 additional answers

Sort by: Most 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.