Unable to use Azure Durable entities from Durable orchestration function in .NET 6 isolated azure functions
See original GitHub issueHi All,
I’m using Azure function in .NET 6 isolated mode. I’m using azure durable entities also. My intent is to call Azure durable entities from Azure durable orchestration. I have added the below reference <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="2.9.2" />
My orchestration code is as below
namespace AzureSagaFunctionApp.Orchestration
{
public static class AzureSagaOrchestrator
{
[Function(nameof(AzureSagaOrchestrator))]
public static async Task<bool> RunOrchestrator(
[Microsoft.Azure.Functions.Worker.OrchestrationTrigger] IDurableOrchestrationContext context, ILogger iLogger)
{
ILogger logger = context.CreateReplaySafeLogger(iLogger);
var userInput = context.GetInput<UserInputRequestMessage>();
var gameEntityId = new EntityId(nameof(GameService), userInput.GameId);
var userCredit = new EntityId(nameof(UserCreditService), $"{userInput.UserId}_{userInput.GameId}");
var gameObj = context.CallEntityAsync(gameEntityId, "GetGameAsync", userInput.GameId);
//replace with entity triggers and not activity tiggers
// returns ["Hello Tokyo!", "Hello Seattle!", "Hello London!"]
return true;
}
[Function("StartOrchestration")]
[OpenApiOperation(operationId: "HttpStart", tags: new[] { "StartOrchestration" })]
[OpenApiSecurity("function_key", SecuritySchemeType.ApiKey, Name = "code", In = OpenApiSecurityLocationType.Query)]
[OpenApiRequestBody("application/json", typeof(UserInputRequestMessage))]
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(StandardResponse), Description = "The OK response")]
public static async Task<HttpResponseMessage> HttpStart(
[HttpTrigger(AuthorizationLevel.Anonymous, "post")] HttpRequestData req,
[Microsoft.Azure.Functions.Worker.DurableClient] DurableTaskClient client,
FunctionContext executionContext)
{
ILogger logger = executionContext.GetLogger("StartOrchestration");
var userInputJson = new StreamReader(req.Body).ReadToEnd();
var userInputs = JsonConvert.DeserializeObject<UserInputRequestMessage>(userInputJson);
// Function input comes from the request content.
string instanceId = await client.ScheduleNewOrchestrationInstanceAsync(
nameof(AzureSagaOrchestrator), userInputs);
var standardResponse = new StandardResponse { OperationStatus = 200, Status = $"Started orchestration with ID = '{instanceId}'." };
var response = new HttpResponseMessage {
Content = new StringContent(JsonConvert.SerializeObject(standardResponse),Encoding.UTF8,"application/json"),
StatusCode=HttpStatusCode.Created,ReasonPhrase="Orchestration started"};
logger.LogInformation("Started orchestration with ID = '{instanceId}'.", instanceId);
return response;
// 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);
}
}
}
My program.cs is as below
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults(worker=> worker.UseNewtonsoftJson())
.ConfigureServices((hostBuilderContext, services)=>
{
services.AddMongoDbClient(hostBuilderContext.Configuration["ConnectionString"]);
services.AddSingleton<IUserRepository, UserRepository>();
services.AddSingleton<IGameRespository,GameRespository>();
services.AddSingleton<IUserCreditRepository, UserCreditRepository>();
services.AddSingleton<IVotingRepository, VotingRepository>();
services.AddLogging();
services.AddDurableClientFactory();
})
.ConfigureOpenApi()
.Build();
host. Run();
When I execute the StartOrchestration function, The orchestration function never executes. Could you please tell me what should I do get my orchestration function started? I’m currently running the code on my local and I will be hosting the same in Azure functions.
Issue Analytics
- State:
- Created 7 months ago
- Comments:12 (2 by maintainers)
Top Results From Across the Web
Unable to use Azure Durable entities from ...
Hi All, I'm using Azure function in .NET 6 isolated mode. I'm using azure durable entities also. My intent is to call Azure...
Read more >Unable to use Azure Durable entities from ...
I'm using Azure function in .NET 6 isolated mode. I'm using azure durable entities also. My intent is to call Azure durable entities...
Read more >Developer's Guide to Durable Entities in .NET
Learn what durable entities are and how to use them in the Durable Functions extension for Azure Functions.
Read more >Overview of Durable Functions in the .NET isolated worker
Learn how to implement eternal orchestrations by using the Durable Functions extension for Azure Functions. Orchestration function replay and ...
Read more >Bindings for Durable Functions (Azure Functions)
The Durable Functions extension introduces three trigger bindings that control the execution of orchestrator, entity, and activity functions ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We are aiming for this September for entitity support in dotnet isolated.
Durable Entities is not yet supported on the .NET Isolated worker, as explained here:
FYI @lilyjma we should probably update the stateful entities conceptual guide to also make this clear.