0

i am facing a weird issue. Searched for multiple question but didn't really get the real fix for this. I have below default template code.

 [FunctionName("OrchFunction_HttpStart")]
    public async Task<HttpResponseMessage> HttpStart(
        [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestMessage req,
        [DurableClient] IDurableOrchestrationClient starter,
        ILogger log)
    {
        // Function input comes from the request content.
        string instanceId = await starter.StartNewAsync("OrchFunction", null);

        log.LogInformation($"Started orchestration with ID = '{instanceId}'.");

        return starter.CreateCheckStatusResponse(req, instanceId);
    }

In Orchstrator function i have below code

[FunctionName("OrchFunction")]
        public  async Task<List<string>> RunOrchestrator(
            [OrchestrationTrigger] IDurableOrchestrationContext context)
        {
            var outputs = new List<string>();
            var data = context.GetInput<JobPayload>();
            var inst=context.InstanceId;
           

            // returns ["Hello Tokyo!", "Hello Seattle!", "Hello London!"]
            return outputs;
        }

Issue here is i am getting NULL in var data = context.GetInput<JobPayload>();. Not sure why, as its the T type i am passing in the HttpRequestMessage. i know its wrong but tried with var data = context.GetInput<HttpResponseMessage>(); , stil its null. What is wrong here? i am getting context.InstanceId value.

lokanath das
  • 736
  • 1
  • 10
  • 35

1 Answers1

2

https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.webjobs.extensions.durabletask.idurableorchestrationclient.startnewasync?view=azure-dotnet#Microsoft_Azure_WebJobs_Extensions_DurableTask_IDurableOrchestrationClient_StartNewAsync_System_String_System_String_

Here are different overloads for StartNewAsync. The one you are using does not pass any input to the orchestrator so you wont have any input in orchestrator. Use this as the starter

 [FunctionName("OrchFunction_HttpStart")]
    public async Task<HttpResponseMessage> HttpStart(
        [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestMessage req,
        [DurableClient] IDurableOrchestrationClient starter,
        ILogger log)
    {
        var payload = new JobPayload()
        {
          //Fill with data
        }
        // Function input comes from the request content.
        string instanceId = await starter.StartNewAsync<JobPayload>("OrchFunction", payload);

        log.LogInformation($"Started orchestration with ID = '{instanceId}'.");

        return starter.CreateCheckStatusResponse(req, instanceId);
    }

Note: JobPayload has to be serializable

Bjorne
  • 1,424
  • 7
  • 13