'azure durable function saving the same data multiple times/duplicating data
Im converting a long running azure function to durable functions. The workflow is as follows:
- durable function 1 gets config data from keyvault & environment variables and returns them in a dictionary.
- second durable function takes this dictionary, connects to a database and checks a database to see if this is a full load or delta load.
- third durable function takes the dictionary of config values and queries active directory via graph API to get all or delta of users. This last function calls a regular method to save each "page" of 200 users received from Active Directory to a database.
We have 40,000 users, but when the process completes, there are 70,000+ records saved, many of which are duplicates.
Questions
- Are these duplicates because of the non durable regular method used to send the data to the database, or something else?
- is there any issue with a durable function calling a normal method/function or can this cause issues?
Update: I can see in the output that one of the durable functions is being executed 5 times, even though i only call it once. i have no idea why this is.
Update2:
Ive stepped through saving the first page of data. the code only executes once, but the data is stored twice!
Does azure functions spin up multiple instances or have some scaling that could cause this to happen?
Solution 1:[1]
Hard to tell without seeing the orchestrator function code.
The orchestrator function code should be deterministic as explained in these docs. Perhaps this is not the case and the GetUsersFromAD activity gets called with different input arguments each time the orchestrator function replays?
Debugging an orchestrator function can be confusing due to the replay nature. If you want more info on how Durable Functions work (incl the checkpointing & replay) this video can help.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

