2

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.

Salvatore Nedia
  • 302
  • 2
  • 15

1 Answers1

6

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"
    }
  ]
}
Cindy Pau
  • 13,085
  • 1
  • 15
  • 27
  • Thanks for the reply! that was almost what I did.. seeing at your answer I think I can leave out req: 'func.HttpRequest,' and that stuff about http? I was looking for smt for triggering with only CRON schedule. The main will contain only two lines like this? client = df.DurableOrchestrationClient(starter) instance_id = await client.start_new("MyOrchestrator", None, None) – Salvatore Nedia Dec 11 '20 at 08:45
  • @SalvatoreNedia Just change the start function trigger is ok. – Cindy Pau Dec 11 '20 at 08:54