pythonazureazure-functionsazure-durable-functions

Create Azure TimerTrigger Durable Function in python


As I claimed in the title, is possible to have an azure durable app that triggers using TimerTrigger and not only httpTrigger? I see here https://learn.microsoft.com/en-us/azure/azure-functions/durable/quickstart-python-vscode a very good example on how implement it with HttpTrigger Client and I'd like to have an example in python on how do it with a TimerTrigger Client, if it's possible.

Any help is appreciate, thanks in advance.


Solution

  • Just focus on the start function is ok:

    __init__py

    import logging
    
    import azure.functions as func
    import azure.durable_functions as df
    
    
    async def main(mytimer: func.TimerRequest, starter: str) -> None:
        client = df.DurableOrchestrationClient(starter)
        instance_id = await client.start_new("YourOrchestratorName", None, None)
    
        logging.info(f"Started orchestration with ID = '{instance_id}'.")
    

    function.json

    {
      "scriptFile": "__init__.py",
      "bindings": [
        {
          "name": "mytimer",
          "type": "timerTrigger",
          "direction": "in",
          "schedule": "* * * * * *"
        },
        {
          "name": "starter",
          "type": "orchestrationClient",
          "direction": "in"
        }
      ]
    }