Skip to content

Set X-MS-COLDSTART header in Flex environments #11074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from
Draft

Conversation

Copilot
Copy link

@Copilot Copilot AI commented May 22, 2025

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 Copilot AI changed the title [WIP] X-MS-COLDSTART header not set in Flex Set X-MS-COLDSTART header in Flex environments May 22, 2025
@Copilot Copilot AI requested a review from liliankasem May 22, 2025 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

X-MS-COLDSTART header not set in Flex
2 participants