azure-functions-durable-extension: Unable to use Azure Durable entities from Durable orchestration function in .NET 6 isolated azure functions

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 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.

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 18 (4 by maintainers)

Most upvoted comments

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:

Not all features from in-process Durable Functions have been migrated to the isolated worker yet. Some known missing features that will be addressed at a later date are:

  • Durable Entities
  • CallHttpAsync

FYI @lilyjma we should probably update the stateful entities conceptual guide to also make this clear.