Azure/azure-functions-dotnet-worker

Add profile condition to FunctionsNetHost worker config to check host is in placeholder mode

kshyju opened this issue · 0 comments

Description

Our logs show that the FunctionsNetHost process is starting after the host instance is specialized. Ideally, FNH should start only in placeholder mode.

FunctionsLogs
| where TIMESTAMP > ago(1h)
| where Summary endswith "Starting FunctionsNetHost"
| where AppName !has "placeholdertemplate"
| distinct AppName
| take 100

We should add one more condition to the worker.config.json file which will check for the environment variable value to determine whether we are in placeholder mode or not.

{
  "conditionType": "environment",
  "conditionName": "INITIALIZED_FROM_PLACEHOLDER",
  "conditionExpression": "(?i)true$"
}

Update: After further investigation, I discovered that the INITIALIZED_FROM_PLACEHOLDER environment variable value remains unchanged after specialization. Instead, the WEBSITE_PLACEHOLDER_MODE variable is the appropriate one to check. In Linux, this variable's value is 1 during placeholder mode and changes to 0 after specialization. Additionally, the WEBSITE_CONTAINER_READY variable starts at 0 in placeholder mode and switches to 1 post-specialization. On Windows, WEBSITE_PLACEHOLDER_MODE is 1 during placeholder mode and appears to be removed after specialization.

Azure/azure-functions-host#9932 is a blocker for making this change.