This is a .net8, Azure Functions v4, dotnet-isolated project. I’m getting the following exception:
System.InvalidOperationException: ‘An invalid asynchronous invocation was detected. This can be caused by awaiting non-durable tasks in an orchestrator function’s implementation or by middleware that invokes asynchronous code.’
To my knowledge there is no middleware
This happens when adding the sub orchestrator task to parallelTasks
. I’ve attempted to make the code as minimal as possible, even hardcoding a return value from the sub orchestrator to remove any async calls. Normally the sub orchestrator has a ctx.CallHttpAsync()
method in it but the same exception happens when I await
that.
As this is an upgrade to dotnet isolated I feel like I’m missing something obvious here – thank you for any help!
This is the Orchestrator:
public async Task<bool> StudentEnrollmentUpdated(
[OrchestrationTrigger] TaskOrchestrationContext ctx,
StudentEnrollment studentEnrollment,
FunctionContext executionContext
)
{
...
...
var parallelTasks = new Task<PlatformEnrollmentMessage>[pqcs.Count];
ServiceBusMessageBatch batch = await _sender.CreateMessageBatchAsync();
try
{
for (var i = 0; i < pqcs.Count; i++)
{
var inputs = new CreatePlatformEnrollmentMessageInputs()
{
QuizConfiguration = pqcs[i],
User = ltiUser,
Enrollment = studentEnrollment,
DeliveryData = customData
};
parallelTasks[i] = ctx.CallSubOrchestratorAsync<PlatformEnrollmentMessage>("SO_CreatePlatformEnrollmentMessage", inputs);
}
}
catch (Exception ex)
{
var d = true;
}
...
...
}
And this is the SubOrchestrator
[Function("SO_CreatePlatformEnrollmentMessage")]
public async Task<PlatformEnrollmentMessage> CreatePlatformEnrollmentMessage(
[OrchestrationTrigger] TaskOrchestrationContext ctx,
CreatePlatformEnrollmentMessageInputs inputs
)
{
return new PlatformEnrollmentMessage
{
Id = 123,
PlatformQuizConfigurationId = 456,
UserId = 1
};
}