I have a basic Azure function that starts with a timmer (1 min for testing), but after hours of trying to make it work, I can't get my data from the firestore.
The trigger:
[FunctionName("OrchestrationTriggerFunction")]
public async static Task OrchestrationTriggerFunction(
[TimerTrigger("0 */1 * * * *")] TimerInfo myTimer,
[DurableClient] IDurableOrchestrationClient starter)
{
await starter.StartNewAsync("Function1", null);
}
Function1:
[FunctionName("Function1")]
public async Task Function1(
[OrchestrationTrigger] IDurableOrchestrationContext context
)
{
List<string> OrgsToProcess = new List<string>() { "ID" };
foreach (string org in OrgsToProcess)
{
var vehicles = await context.CallActivityAsync<List<Vehicle>>("GetFirestoreVehicles", org);
var parallelTasks = new List<Task<Result>>();
foreach (var vehicle in vehicles)
{
// processing code
Task<CsvResult> task = context.CallActivityAsync<Result>("ProcessData", msg);
parallelTasks.Add(task);
}
await Task.WhenAll(parallelTasks);
await context.CallActivityAsync("Function2", parallelTasks);
return;
}
}
GetFirestoreVehicles:
[FunctionName("GetFirestoreVehicles")]
public Task<List<Vehicle>> GetFirestoreVehicles([ActivityTrigger] string org)
{
return _firestoreDb.GetVehicles(org);
}
In Function1, on var vehicles = await context.CallActivityAsync<List<Vehicle>>("GetFirestoreVehicles", org);
I can see that it has the correct number of records, however all the properties are filled with null.
When looking at the GetFirestoreVehicles
during the debugging it says Result = "{Not yet computed}"
and I'm unable to use await
in my firestore method as it throws the following exception:
multithreaded execution was detected. This can happen if the orchestrator function code awaits on a task that was not created by a DurableOrchestrationContext method
How can I make my Durable Function await the data from firestore?
>("GetFirestoreVehicles", org);` with the firestore call directly, I'm able to get the vehicles data but then I get the `multithreaded execution was detected.` exception
– João Silva Mar 15 '23 at 13:21>("GetFirestoreVehicles", org);` and it still did not work?
– Peter Bons Mar 15 '23 at 13:51