question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 7 months ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jviaucommented, Jul 6, 2023

We are aiming for this September for entitity support in dotnet isolated.

1reaction
cgillumcommented, Mar 6, 2023

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.

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found