Azure / Azure/azure-functions-durable-python
create or get instance of orchestrator
- Dominant language
- Python
- Stars
- 157
- Forks
- 70
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 2
Description
I was creating a orchestration that was waiting for three events (from EventGrid) and then calls another two activities and got it working, but noticed that my code is needlessly complex, this is what happens in my trigger (with EventHubTrigger), after creating a blob object with a order_id attribute, I need this code:
```python
try:
status = await client.get_status(blob.order_id)
instance_id = status.instance_id
except Exception:
instance_id = await client.start_new("Orchestrator", blob.order_id, None)
if instance_id:
await client.raise_event(instance_id, blob.file_type, True)
else:
logging.error("Could not start orchestrator for instance: %s", blob.order_id)
```
I would expect either the `client.start_new` call to either create a new one or get an existing one, or for there to be a something like a `get_or_start_new` function on client.
The reason I needed to do it like this is that I have a single input (EventGrid triggered by storage) and need to both start a orchestration and raise an event, I do have an instance_id I can use to align the different events to the same orchestrator instance but the fact that I can't just have this function call `start_new` three times is very unintuitive and hard to debug.
Contributor guide
Assessment
This issue has not been assessed yet.