azure-functions-host icon indicating copy to clipboard operation
azure-functions-host copied to clipboard

Set X-MS-COLDSTART header in Flex environments

Open Copilot opened this issue 9 months ago • 0 comments

Problem

In Flex environments, the X-MS-COLDSTART header is not being set during specialization, unlike in Windows Consumption where MinIYarp sets this header automatically. This leads to:

  1. request.IsColdStart() incorrectly returning false for the first request after specialization
  2. Missing cold start logs and telemetry data
  3. Missing FaaSColdStart tag in Activity tracking

Changes

  • Modified PlaceholderSpecializationMiddleware to set the X-MS-COLDSTART header during specialization, but only for Flex environments
  • Added unit tests to verify the behavior in different scenarios:
    • Header is set for Flex environments during specialization
    • Header is not set for non-Flex environments
    • Header is not set when no specialization occurs

Implementation Details

The changes are minimal and focused on adding the header to the current HTTP request context when specialization happens in a Flex environment:

// For Flex environments, set the cold start header during specialization
// since it's not automatically set by the platform like in Windows Consumption
if (_environment.IsFlexConsumptionSku())
{
    httpContext.Request.Headers[ScriptConstants.AntaresColdStartHeaderName] = "1";
}

These changes ensure that cold start detection works correctly across all environments, maintaining consistency between Windows Consumption and Flex.

Fixes #11053.

[!WARNING]

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • azfunc.pkgs.visualstudio.com
    • Triggering command: dotnet build (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)
    • Triggering command: dotnet tool install -g dotnet-format (dns block)
  • cdn.fwupd.org
    • Triggering command: /usr/bin/fwupdmgr refresh (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar May 22 '25 20:05 Copilot