Using a Durable Functions template I've created a function that simply starts execution of a method by calling the generated SendEventPostUri request which starts a timer of 60 minutes and completes after the expiration of those minutes.
http://localhost:7228/runtime/webhooks/durabletask/instances/{instanceId}/raiseEvent/{eventName}?code={code}
This works but now I want to send 2 more requests so there are a total of 3 requests running the same method simultaneously at staggered start times and then get the status of each of the requests for the same orchestrator in a JSON response collection but cannot figure out how to do it.
I tried posting the same URI a couple of times but the console output doesn't suggest that there are any more than 1 instance of the method "InitiateDurableFunction" being called or running.
Instead I get a new instance of the Orchestrator, which isn't what I wanted to do.
I can see the status of each new Orchestrator instance using
http://localhost:7228/runtime/webhooks/durabletask/instances/{orchestratorId}?code={code}
How can I start the same method within 1 Orchestrator multiple times or is my expectation not possible?
Also, if this question is a duped post. I cannot find it.
Each orchestration instance in Azure Durable Functions is isolated , meaning you can't run multiple parallel executions of the same method within a single instance.
Instead, you need to start multiple orchestrator instances, each handling its own execution.
Use the HTTP Start Endpoint .Instead of raiseEvent
, use the startNew
endpoint to create new orchestrator instances:
POST http://localhost:7228/api/orchestrators/InitiateDurableFunction?code={functionKey}
Call this endpoint three times (with staggered delays if needed), and each call will create a new instance.
Each response will return a unique instanceId
. Store these IDs so you can later query their statuses individually:
GET http://localhost:7228/runtime/webhooks/durabletask/instances/{instanceId}?code={functionKey}
If you want a JSON collection of all statuses, you can write a simple HTTP-triggered function that takes a list of instance IDs and returns their statuses by querying the Durable Task API for each.
Alternative Approach: If you're looking for parallel execution within a single orchestrator, consider using fan-out/fan-in patterns. This allows you to start multiple activity functions in parallel and wait for their completion before aggregating results.