Reputation: 352
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.
Upvotes: 3
Views: 2579
Reputation: 345
Updated for 2024 using Python and the v2 programming model
@app.schedule(arg_name="myTimer", schedule="30 * * * * *")
@app.durable_client_input(client_name="client")
async def mytimer(myTimer: func.TimerRequest, client: df.DurableOrchestrationClient):
instances = await client.get_status_all()
for instance in instances:
print(instance)
Upvotes: 0
Reputation: 14088
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"
}
]
}
Upvotes: 6