Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 241
Salvatore Nedia Avatar asked May 13 '26 18:05

Salvatore Nedia


1 Answers

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"
    }
  ]
}
like image 173
Cindy Pau Avatar answered May 16 '26 08:05

Cindy Pau



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!