I have the following setup to test my Durable Function.
public class TestDurableFunction
{
private readonly ITestRepository _testRepository;
public TestDurableFunction(ITestRepository testRepository)
{
_testRepository = testRepository; // needed for later use
}
[FunctionName("TimerTrigger")]
public async Task Run([TimerTrigger("0 1 * * *", RunOnStartup = true)] TimerInfo myTimer, [DurableClient] IDurableClient starter, ILogger logger)
{
try
{
await starter.StartNewAsync("OrchestrateSavings", null);
}
catch (Exception exception)
{
logger.LogFunctionError(nameof(Run), nameof(TestDurableFunction), exception);
}
}
[FunctionName("OrchestrateTest")]
public async Task<int> OrchestrateTest([OrchestrationTrigger] IDurableOrchestrationContext context)
{
await Task.CompletedTask;
return 10;
}
}
When I start this function locally, then the TimerTrigger function starts with no problems. This function then calls my OrchestrateTest Durable Function.
But that immediately throws the following error in the Command Prompt window:
Microsoft.Azure.WebJobs.Script.WebHost: Unable to load metadata for function 'OrchestrateTest'. Function 'OrchestrateTest (Orchestrator)' was aborted. Reason: An internal error occurred while attempting to execute this function. The execution will be aborted and retried. Details: System.NullReferenceException: Object reference not set to an instance of an object.
Anyone any idea what the issue could be?