Set X-MS-COLDSTART header in Flex environments
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:
-
request.IsColdStart()incorrectly returningfalsefor the first request after specialization - Missing cold start logs and telemetry data
- Missing
FaaSColdStarttag in Activity tracking
Changes
- Modified
PlaceholderSpecializationMiddlewareto 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:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to my firewall allow list
💡 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.