Hi @Umar Al-Faruq
Thank you for reaching out to Microsoft Q&A.
I received a response from the backend team, and this is a platform side issue reported by multiple customers.
Please find the Root cause and recommended workaround for you to resolve this issue:
Root Cause
The root cause is a system key synchronization race condition on Flex Consumption cold starts:
With alwaysReadyInstances: 0, the app scales to zero between events
When Event Grid delivers an event, FPS allocates a new pod (cold start)
During pod startup, the Functions host must load the eventgrid_extension system key from BlobStorageSecretsRepository
The request may arrive at the pod's HTTP endpoint before the system key has been loaded into memory
The webhook authentication middleware cannot validate the system key → returns 401 Unauthorized
Because the 401 occurs before the function is invoked, no App Insights traces are generated for failed deliveries
Why this worked on Consumption plan: Classic Consumption uses a placeholder/warm-standby instance model where keys are pre-loaded. Flex Consumption with alwaysReadyInstances: 0 has no warm instance, so every request after scale-to-zero hits a cold start.
Why it is intermittent: The race depends on timing — if the key loads before the request arrives, the request succeeds (200). If the request arrives first, it fails (401). Additionally, Blob Storage errors during startup exacerbate the issue.
Confidence level: High. Evidence chain: 100% cold-start correlation for 401s + system key loading on every pod startup + Blob Storage write errors during initialization + zero App Insights traces (401 before function invocation) + works on Consumption plan (warm instances).
Recommendations
- Immediate workaround: Set alwaysReadyInstances to at least 1 for the http function group. This ensures a warm instance is always available with the system key pre-loaded, eliminating the cold start race condition.
az functionapp config set --name xxxx-xx-xx-txxxt --resource-group txxxxg-txxt \
--always-ready-instances http=1
- Upgrade Node.js runtime: The app is running Node.js v20, which reached EOL in April 2026. Upgrade to Node.js v22 to receive security patches and performance improvements.
- Alternative workaround: If setting alwaysReadyInstances is not desired (cost), consider switching the Event Grid subscription destination type from AzureFunction (resource-based) to a Webhook destination with the function URL and ?code= key embedded directly. This may behave differently during key validation.
- Set WEBSITE_RUN_FROM_PACKAGE=1: FunctionsLogs show "Set 'WEBSITE_RUN_FROM_PACKAGE' to '1' to significantly improve load times" and "Loading 'index.js' took 1067ms". This will reduce cold start time and narrow the race window.
- Platform follow-up: The Flex Consumption platform should ensure system keys are loaded from Blob Storage before marking the pod as ready to receive webhook requests. This is a platform-level gap.
Node.js v20 EOL warnings: FunctionsLogs show repeated "Node.js v20 reached EOL on 2026-04. Please upgrade to a supported version" warnings on every instance.