Does azure durable function support corn jobs. I need a set of tasks to run every 5 mins. When going though the timer section of azure durable function did not see any example for setting cron job settings for durable functions
-
You can use a CRON trigger to _Start_ a Durable function (which may itself be eternal) This is indirectly explained here: https://stackoverflow.com/a/59582109/1690217 – Chris Schaller Jun 18 '21 at 00:12
3 Answers
Depending on you scenario, you can use normal Timer Triggers by Functions (not Durable). Or you can use Eternal Orchestrations that wake up periodically by Durable.

- 770
- 2
- 10
- 25
Yes and No,
Durable functions framework provides a way to run the orchestrator function periodically, refer below code
await context.CallActivityAsync("DoCleanup", null);
// sleep for one hour between cleanups
DateTime nextCleanup = context.CurrentUtcDateTime.AddHours(1);
await context.CreateTimer(nextCleanup, CancellationToken.None);
context.ContinueAsNew(null);
The above piece of code will call your activity function DoCleanup every hour.
The problem with normal timer trigger functions are they runs into overlap issue. for example if you want to run something every 1-minute and if your function execution takes 30 seconds then you will face overlap issues.
With durable the above problem is solved. It guarantees no overlap.
The only issue is this orchestration function needs to be externally triggered one time by some durable client and cannot be self started like timer trigger azure functions.
`

- 11
- 1
Seems like things might have changed since the question was asked. Also, I didnt see a specific language you were using, so I am describing the procedure in python, but the same is applicable for the other supported languages.
I found that you can modify the template for "Timer trigger" function and the function itself to be able to act like a "Durable Functions HTTP starter". To replicate:
- Create your functions (Orchestrator, Activity and Timer) from a template (here via CLI, but also via VS)
func new -t "Durable Functions orchestrator"
func new -t "Durable Functions activity"
func new -t "Timer trigger"
- Modify the function.json in the Timer function to add the
durableClient
input.
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "mytimer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 */5 * * * *"
},
{
"name": "starter",
"type": "durableClient",
"direction": "in"
}
]
}
- Modify your function to act asynchronly and to use the input. If you named your function something different from the default
DurableFunctionsOrchestrator
you should modify the input toclient.start_new
to match what you named it
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(
'DurableFunctionsOrchestrator', None, None)
logging.info(f"Started orchestration with ID = '{instance_id}'.")
- Modify your requirements.txt to add
azure-functions-durable
azure-functions
azure-functions-durable
- Now you can deploy and watch it work
func azure functionapp publish labrix-househunt
Its working well for me!

- 605
- 1
- 13
- 30