-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Visual Studio: New Durable Functions Project: System.InvalidOperationException: Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead. #2425
Labels
potential-bug
Items opened using the bug report template, not yet triaged and confirmed as a bug
Comments
jaliyaudagedara
added
the
potential-bug
Items opened using the bug report template, not yet triaged and confirmed as a bug
label
Apr 22, 2024
This was a known issue for some time, and I saw the template was fixed on this PR (Azure/azure-functions-templates#1513). Related issues:
But somehow VS isn't using the updated templates. The code generated by VS,
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.DurableTask;
using Microsoft.DurableTask.Client;
using Microsoft.Extensions.Logging;
namespace FunctionApp1
{
public static class Function1
{
[Function(nameof(Function1))]
public static async Task<List<string>> RunOrchestrator(
[OrchestrationTrigger] TaskOrchestrationContext context)
{
ILogger logger = context.CreateReplaySafeLogger(nameof(Function1));
logger.LogInformation("Saying hello.");
var outputs = new List<string>();
// Replace name and input with values relevant for your Durable Functions Activity
outputs.Add(await context.CallActivityAsync<string>(nameof(SayHello), "Tokyo"));
outputs.Add(await context.CallActivityAsync<string>(nameof(SayHello), "Seattle"));
outputs.Add(await context.CallActivityAsync<string>(nameof(SayHello), "London"));
// returns ["Hello Tokyo!", "Hello Seattle!", "Hello London!"]
return outputs;
}
[Function(nameof(SayHello))]
public static string SayHello([ActivityTrigger] string name, FunctionContext executionContext)
{
ILogger logger = executionContext.GetLogger("SayHello");
logger.LogInformation("Saying hello to {name}.", name);
return $"Hello {name}!";
}
[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 client.CreateCheckStatusResponse(req, instanceId);
}
}
} |
The templates have been updated: Azure/azure-functions-templates#1513 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
potential-bug
Items opened using the bug report template, not yet triaged and confirmed as a bug
Description
When creating a new Azure Function App Project and selecting
Durable Functions Orchestration
, the basic functionality is erroring out when the defaultFunction1_HttpStart
is triggered.Error:
System.InvalidOperationException: Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead.
Visual Studio Version:
Steps to reproduce
Durable Functions Orchestration
Function1_HttpStart
endpointThe text was updated successfully, but these errors were encountered: