Azure durable functions orchestrator error: Value cannot be null. (Parameter 'logger') when calling Activity Function

Roger Wagy 45 Reputation points
2025-10-27T16:15:39.8233333+00:00

Azure durable functions .net 8 orchestrator error on second pass:
"Value cannot be null. (Parameter 'logger') "
when calling Activity Function. It seems that the logger parameter is null when calling the activity function. The activity function never runs, just errors out with no useful information. I am not sure how to create a logger instance inside the activity function. Dependency injection is not working, but I am not an expert on DI.
Activity Function signature:
public static async Task<Customer_SQL> CustCreate_1([ActivityTrigger]

      Customer_Json.Rootobject c, ILogger logger)
Azure App Configuration
Azure App Configuration
An Azure service that provides hosted, universal storage for Azure app configurations.
{count} votes

Answer accepted by question author
  1. Rupesh Asati 1,020 Reputation points Microsoft External Staff Moderator
    2025-10-27T17:10:36.8733333+00:00

    Hello Roger Wagy

    Thanks for reaching out on Microsoft Q&A and really appreciate your patience while we looked into this.

    Understand from description that you're running into .NET 8 Durable Functions activity logger issue.

    Steps:

    1.Use FunctionContext.GetLogger()

    [Function("CustCreate_1")]
    public async Task<Customer_SQL> CustCreate_1(
        [ActivityTrigger] Customer_Json.Rootobject c,
        FunctionContext context)
    {
        var logger = context.GetLogger("CustCreate_1"); 
        logger.LogInformation("Activity started");
    
        return new Customer_SQL();
    }
    
    1. FunctionContext is automatically supplied by the runtime.
    2. Logger obtained this way is replay-safe.
    3. Do not pass ILogger as a parameter.

    Microsoft Learn – Logging in isolated process functions

    2.Use Constructor Dependency Injection

    public class MyActivities
    {
        private readonly ILogger<MyActivities> _logger;
    
        public MyActivities(ILogger<MyActivities> logger)
        {
            _logger = logger;
        }
    
        [Function("CustCreate_1")]
        public async Task<Customer_SQL> CustCreate_1([ActivityTrigger] Customer_Json.Rootobject c)
        {
            _logger.LogInformation("Activity started");
            return new Customer_SQL();
        }
    }
    
    1. ILogger is injected via DI.
    2. Works correctly with replay scenarios.

    Microsoft Learn – Dependency injection in isolated process

    1.Do not pass non-serializable types (ILogger, HttpContext, CancellationToken) as activity function parameters.

    2.Use only serializable POCOs, strings, primitives as activity inputs.

    If issue persists, please provide the below information via private message:

    • Durable Functions version
    • Full activity function code
    • How orchestrator calls the activity
    • Any custom serialization or middleware

    Kindly let us know if the above helps or you need further assistance on this issue.

    Please Accept the Answer if the information helped you. This will help us and others in the community as well.

    Thanks

    Thanks

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.