When creating a new Azure Function App Project and selecting Durable
Functions Orchestration, right now the basic functionality is erroring out
when the default Http Function is triggered.
Error: System.InvalidOperationException: Synchronous operations are
disallowed. Call WriteAsync or set AllowSynchronousIO to true instead.
Unfortunately, this is a known issue (https://github.com/Azure/azure-functions-dotnet-worker/issues/2425) with the templates and hopefully, the templates will get updated soon.
For the time being, you can update the code in the HttpStart function to use
CreateCheckStatusResponseAsync as follows.
[Function("Function1_HttpStart")]
public static async Task<HttpResponseData> HttpStart(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req,
[DurableClient] DurableTaskClient client,
FunctionContext executionContext)
{
ILogger logger = executionContext.GetLogger("Function1_HttpStart");
// Function input comes from the request content.
string instanceId = await client.ScheduleNewOrchestrationInstanceAsync(
nameof(Function1));
logger.LogInformation("Started orchestration with ID = '{instanceId}'.", instanceId);
// Returns an HTTP 202 response with an instance management payload.
// See https://learn.microsoft.com/azure/azure-functions/durable/durable-functions-http-api#start-orchestration
return await client.CreateCheckStatusResponseAsync(req, instanceId);
}
Hope this helps.
Happy Coding.
Regards,
Jaliya
No comments:
Post a Comment