Unable to see the attributes under customdimenstions of Application insights when set the attributes using ILogger.BeginScope

Rayappa Bankapur (CSEC) 0 Reputation points
2026-09-09T13:57:59.5933333+00:00

was trying to set attribute and its value using ILogger.BeginScope in Azure function. theory says when we set the attributes using ILogger.BeginScope, we can see those attributes under customdimensions section of Application insights. have tried and troubleshooted possible ways but don't see those attributes in Application insights. Is there proven steps/configurations? please share with me.

Azure Functions
Azure Functions

An Azure service that provides an event-driven serverless compute platform.


2 answers

Sort by: Most helpful
  1. Paul Thomas 0 Reputation points
    2026-10-02T11:58:22.5333333+00:00

    I reproduced this to see exactly what reaches Application Insights. In the .NET isolated worker, two things decide whether your scope values show up in customDimensions.

    1. The log has to reach Application Insights at all

    With AddApplicationInsightsTelemetryWorkerService(), the Application Insights logger only sends Warning and above by default. In my test, a LogInformation call inside a scope sent nothing at all, while LogWarning arrived with the scope values. The current func init template registers Application Insights but doesn't remove this rule, so new apps hit it straight away.

    Remove the default rule in Program.cs:

    var
    

    2. Pass the scope as key/value pairs

    What you pass to BeginScope decides how it's stored. These are the results from my test:

    Scope passed to BeginScope What appears in customDimensions
    Dictionary<string, object> Each key as its own field: OrderId, CustomerId
    Dictionary<string, object> Each key as its own field: OrderId, CustomerId
    Message template: BeginScope("Processing order {OrderId}", orderId) OrderId as its own field
    Plain string: BeginScope("OrderId=A-1001") One Scope field containing the text
    Anonymous object: BeginScope(new { OrderId = "A-1001" }) One Scope field containing the text

    So use a dictionary:

    using
    

    Then check in Application Insights:

    traces
    | where timestamp > ago(30m)
    | where message == "Order received"
    | project timestamp, message, customDimensions
    

    You should see OrderId and CustomerId as separate entries in customDimensions.

    If your app uses the in-process model (FUNCTIONS_WORKER_RUNTIME = dotnet), the logs go through the Functions host instead, and the keys may appear with a prop__ prefix, as Tejaswini mentioned.

    Was this answer helpful?

    0 comments No comments

  2. Tejaswini Billakurthi 760 Reputation points Microsoft External Staff Moderator
    2026-09-09T14:30:19.93+00:00

    Hello @Rayappa Bankapur (CSEC) ,

    Thank you for reaching out to Microsoft Q & A!

    There are a couple of common reasons why BeginScope values don't appear as individual customDimensions entries:

    Verify the type passed to BeginScope. Application Insights expands scope values into custom properties only when the scope is an IReadOnlyCollection<KeyValuePair<string, object>> (for example, a dictionary). Otherwise, the scope is typically stored under a single Scope property. See: Application Insights logging scopes.

    Verify the property name being queried. For Azure Functions in-process apps, custom properties are often prefixed with prop__. For example, MyKey may appear as customDimensions.prop__MyKey. Reviewing the raw customDimensions payload can help confirm how the properties are stored.

    If using .NET isolated worker, verify that Application Insights is configured directly in the worker process, as scope properties may not be preserved when logs are relayed through the Functions host. See: Azure Functions isolated worker Application Insights guidance.

    Could you confirm whether the Function App is running in-process or .NET isolated, and share a sample customDimensions payload from a trace where the scope values are expected?

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

    Was this answer helpful?

    0 comments No comments

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.