Durable Functions: How to pass a parameter to the Orchestrator?

I am new to Azure Durable functions and have been following the sample code in the book ‘Azure Serverless Computing Cookbook’ and I am stuck because the .GetInput function in my Orchestrator is return null. My Blob trigger is passing the file name as a parameter in the call to my Orchestrator. I think its calling the wrong overloaded function but not sure how to call the correct one.

await starter.StartNewAsync("CSVImport_Orchestrator", name); 
        public static async Task<List<string>> RunOrchestrator([OrchestrationTrigger] IDurableOrchestrationContext context)
            var outputs = new List<string>();
            string CSVFileName = context.GetInput<string>(); //<<== returns null???
                List<Employee> employees = await context.CallActivityAsync<List<Employee>>("ReadCSV_AT", CSVFileName);
            return outputs;

        public static async  void Run([BlobTrigger("import-obiee-report/{name}", Connection = "StorageConnection")]Stream myBlob, string name, [DurableClient]IDurableOrchestrationClient starter, ILogger log)
            string instanceId = await starter.StartNewAsync("CSVImport_Orchestrator", name); 
            log.LogInformation($"C# Blob trigger function Processed blobn Name:{name} n Size: {myBlob.Length} Bytes");

In advance, thank you for your help.


You are calling the non-generic overload of StartAsync(string, string) where the second, string argument represents the InstanceId and not the input argument. There’s also a generic overload where the second argument represents the data. You are passing a string so overload resolution sees two potential candidates. It then prefers the non-generic one since it’s an exact match, thus “losing” your data.

If you really need a string for your input data you will need to specify the generic argument explicitly to force the compiler to select the correct overload:

await starter.StartAsync<string>("CSVImport_Orchestrator", name);

Now, the documentation also states that the input should be a JSON-serializeable object. Technically a string is, but I’m not sure how it plays with the orchestrator’s serializer. You can instead pass a class containing your data. This has the upside that the generic argument will be properly inferred:

public class Data {
   public string Name { get; set; } 

// calling 
await starter.StartAsync("CSVImport_Orchestrator", new Data { Name = name });

// using 
var csvFileName = context.GetInput<Data>()?.Name;

Leave a Reply

Your email address will not be published. Required fields are marked *