Skip to content

Proposal: structured properties in Azure Functions Node.js logging #477

Open

Description

Problem

Need

context.error('External service request failed', {
    service: 'example-api',
    operation: 'fetchData',
    statusCode: 503,
    retryable: true,
});

With structured logging enabled, these properties should appear as separate Application Insights customDimensions, so a failure can be filtered by customDimensions.statusCode without parsing the message.

  • Log a readable message together with application context, such as service, operation, status code and retry information, through existing context.log/error calls.
  • Keep that context as separate Application Insights fields so developers can filter failures, group related events, build alerts and display diagnostic information in their applications without parsing message text.
  • Make this available through the Functions logging API, preserving its familiar usage and invocation correlation instead of requiring application code to use a separate telemetry API for every structured log.

Scope

The three PRs are open and ready for review:

Proposed solution

  • Add optional structured logging through existing context.log/error methods.
  • Preserve current message formatting and default behavior.
  • Export properties as separate Application Insights fields through OpenTelemetry.
  • Discuss the shared approach in this issue and implementation details in the linked PRs.

Activity

  1. added 2 commits that reference this issue on Sep 29, 2026
  2. swapnil-nagar commented on Oct 20, 2026

    @swapnil-nagar
    Contributor

    Thank you for raising this issue, we will review and prioritize by end of Week Oct 23

  3. swapnil-nagar commented on Oct 20, 2026

    @swapnil-nagar
    Contributor

    Thank you for the proposal and the linked PRs. We reviewed the approach and confirmed that structured properties require coordinated changes across the library, worker, and OpenTelemetry integration. The proposed exporter changes also alter default log-forwarding behavior for existing applications, raising backward-compatibility concerns.

    Given those concerns, we are not taking on this work at this time and are moving this item to the backlog for future consideration. We will revisit whether and how this capability should be addressed while preserving existing behavior.

    For now, we recommend the previously suggested workaround from #227: use the Application Insights SDK directly to emit telemetry with custom properties.

  4. timtucker-dte commented on Oct 21, 2026

    @timtucker-dte

    Possible approach that would preserve backward compatibility with legacy applications and keep changes to interfaces to a minimum:

    The function context contains traceContext, which contains an attributes object of type Record<string, string>.

    That's described as "Holds additional properties being sent as part of request telemetry".

    Could a function invocation add to or modify those attributes in order to have additional custom properties propagate to OpenTelemetry spans for logs / Application Insights?

    Example:

    context.traceContext ??= {};
    context.traceContext.attributes ??= {};
    context.traceContext.attributes["foo"] = "Extra info";
    context.info("I like turtles");
    

    Note that the current, Record<string, string> signature does seem to be more limiting that the specs for custom properties for OpenTelemetry. Broadening that to string | number | boolean would probably make sense.

  5. rmaziarka commented on Nov 3, 2026

    @rmaziarka
    Author

    Swapnil Nagar (@swapnil-nagar)

    For now, we recommend the previously suggested workaround from #227: use the Application Insights SDK directly to emit telemetry with custom properties.

    Yeah, but doesn't it require special activity function, when performed in orchestrator? RIght now I can just type:
    context.log('Whatever');
    in orchestrator and it works. Using AI SDK would require special activity call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions