1

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.

Any insights in this regard will be of immense help

I was expecting the function to invoke the orchestration

1 Answer 1

4

Durable entities is not yet supported in isolated mode.

See Overview of Durable Functions in the .NET isolated worker

UPDATE: Support for durable entities was added in version 1.1.0 of the Microsoft.Azure.Functions.Worker.Extensions.DurableTask package

Sign up to request clarification or add additional context in comments.

3 Comments

I missed that paragraph and wasted most of the day trying to retrofit my durable entity :(
@ThomasEyde Hey, I wanted to confirm if durable function is now available in isolated model or not. because at one place its written it is possible and at another place its written its not possible as of now. Can you help me with that?
@PrashantAgrawal Still not supported. Follow the following GitHub issue for updates: github.com/microsoft/durabletask-dotnet/issues/19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.