An Azure service that provides streamlined full-stack web app development.
@Golla Venkata Pavani Apologise the previous reply, which was accidentally pasted twice. The intended message is the first occurrence; please disregard the duplicate."
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Setup: Azure Static Web Apps Standard tier, UK South region (Microsoft.Web/staticSites). Affected endpoint: anonymous public signup POST on our SWA managed Functions deployment.
After multiple successful SWA Actions deploys (most recent: a commit containing fresh diagnostic logging), the running Functions worker continues to execute old code. Diagnostic log markers added in the new deploy do not appear in App Insights despite the deploy reporting success and Oryx confirming fresh artifact build.
Reproduction window: 2026-05-25 between approximately 12:00 and 15:32 UK time (UTC+1). Most recent reproduction:
Reproduced 4 times across 90 minutes plus a separate 60-minute cold-start retry:
mainR1. Node.js require()-cache lifecycle stuck on warm worker.
Ruled out: 60+ minute idle window with zero endpoint traffic, then single cold-start retry, still serves old code. Cold-start by definition forces fresh require().
R2. SWA Actions deploy failure.
Ruled out: all 4 deploys reported success in GitHub Actions. Oryx build log explicitly confirms the new commit SHA is what was built.
R3. App settings causing module init to skip.
Ruled out: appsetting toggle (DIAG_FORCE_RESTART=<unix timestamp>) saved successfully and visible in az staticwebapp appsettings list output. Did not change running behaviour.
R4. Configurable restart via CLI.
Ruled out: az staticwebapp does not expose restart/stop/start/reload subcommands. No separate Microsoft.Web/sites Function App resource exists (confirmed via az resource list -g <our-resource-group>). All Function code encapsulated in the SWA resource.
WEBSITE_RUN_FROM_PACKAGE-style read-only mount serving stale packageThese involve platform internals not visible from customer-side CLI or portal investigation.
A confirmed CLI or portal mechanism (or sequence of mechanisms) that forces SWA managed Functions to serve the most recent deployed code, applicable in scenarios where standard deploy mechanisms have apparently completed successfully but old code continues to run.
Specifically:
Working through pre-production verification discipline before broader rollout. Establishing deploy reliability with the platform is part of that.
az staticwebapp investigation commands runIf anyone else has encountered this pattern on SWA managed Functions, would value hearing your resolution path. Happy to help this thread become a community reference if we find a working mechanism.
An Azure service that provides streamlined full-stack web app development.
@Golla Venkata Pavani Apologise the previous reply, which was accidentally pasted twice. The intended message is the first occurrence; please disregard the duplicate."
Hi @Golla Venkata Pavani Thank you for the detailed analysis and the explicit recommendation that BYOF is the supported architecture for our requirements. We have now executed two tactical bypass attempts per your recommendation framing; both failed, and the evidence empirically confirms your diagnosis.
Test results. Two code-side refactors against /api/public/request-access, each verified on a fresh post-deploy worker:
emailModule.getSuperAdminEmails(...)). Worker cloud_RoleInstance=0--a713afc4-..., first-seen +83 seconds after deploy completion. The module-load marker fired confirming the new shared module was in the require cache, but the function-body entry marker did not fire. The caller's .catch(() => []) resolved to an empty array without the source-defined function body executing.cloud_RoleInstance=0--c428b6fb-..., first-seen +78 seconds after deploy completion. Same outcome — no function-body markers fired. Additionally, a context.warn log call later in the same outer async Promise.allSettled IIFE that successfully reached App Insights under Pattern A was silently dropped under Pattern B, on the same code structure at the same line of caller code — a strict-superset failure mode. Handler latency 186 ms vs Pattern A's 341 ms, consistent with the inline IIFE either not executing or short-circuiting before any work.The strict-superset finding is the decisive piece of evidence. Under standard Node/V8 semantics, replacing a shared-module function call with an equivalent inlined async IIFE cannot cause a previously-working synchronous log call later in the same outer IIFE to silently fail. This is consistent with the managed Functions runtime exhibiting behaviour inconsistent with documented Node module semantics under our configuration (system-assigned MI + Key Vault references on the API layer). No code-side mitigation we have tried has survived it. Your BYOF recommendation is confirmed.
Full evidence trail. Our internal runbook §3.6 documents both tests side-by-side: test conditions, full marker tick tables, fresh-worker cross-check timestamps, the handler-latency delta evidence, and the canonical statement of the strict-superset finding in §3.6.4. Permalink to the file at the current main commit:
Scroll to §3.6 (after §3.5). If the repository's access requires a collaborator grant on your end, please let us know and we will arrange.
Migration timeline. We are scheduling the BYOF migration in the coming week, following a five-phase plan: baseline measurements, resource provisioning, parallel deploy, ≥5 business days of parallel-run validation, decommission of the managed Functions configuration. The Phase 1 baseline inventory is in progress as of this reply.
Three forward-looking architecture questions to inform the migration design, where your team's experience with similar workloads exceeds our local guesswork:
az staticwebapp functions link fully purge any managed-Functions deployment cache before the new Function App becomes authoritative, or is there state coupling we should plan around?We will report back with cutover confirmation and ≥5-day-stable parallel-run results, at which point this ticket can be closed. Thank you again for the substantive guidance — the explicit written recommendation has been valuable in scoping the migration internally.Thank you for the detailed analysis and the explicit recommendation that BYOF is the supported architecture for our requirements. We have now executed two tactical bypass attempts per your recommendation framing; both failed, and the evidence empirically confirms your diagnosis.
Test results. Two code-side refactors against /api/public/request-access, each verified on a fresh post-deploy worker:
emailModule.getSuperAdminEmails(...)). Worker cloud_RoleInstance=0--a713afc4-..., first-seen +83 seconds after deploy completion. The module-load marker fired confirming the new shared module was in the require cache, but the function-body entry marker did not fire. The caller's .catch(() => []) resolved to an empty array without the source-defined function body executing.cloud_RoleInstance=0--c428b6fb-..., first-seen +78 seconds after deploy completion. Same outcome — no function-body markers fired. Additionally, a context.warn log call later in the same outer async Promise.allSettled IIFE that successfully reached App Insights under Pattern A was silently dropped under Pattern B, on the same code structure at the same line of caller code — a strict-superset failure mode. Handler latency 186 ms vs Pattern A's 341 ms, consistent with the inline IIFE either not executing or short-circuiting before any work.The strict-superset finding is the decisive piece of evidence. Under standard Node/V8 semantics, replacing a shared-module function call with an equivalent inlined async IIFE cannot cause a previously-working synchronous log call later in the same outer IIFE to silently fail. This is consistent with the managed Functions runtime exhibiting behaviour inconsistent with documented Node module semantics under our configuration (system-assigned MI + Key Vault references on the API layer). No code-side mitigation we have tried has survived it. Your BYOF recommendation is confirmed.
Full evidence trail. Our internal runbook §3.6 documents both tests side-by-side: test conditions, full marker tick tables, fresh-worker cross-check timestamps, the handler-latency delta evidence, and the canonical statement of the strict-superset finding in §3.6.4. Permalink to the file at the current main commit:
Scroll to §3.6 (after §3.5). If the repository's access requires a collaborator grant on your end, please let us know and we will arrange.
Migration timeline. We are scheduling the BYOF migration in the coming week, following a five-phase plan: baseline measurements, resource provisioning, parallel deploy, ≥5 business days of parallel-run validation, decommission of the managed Functions configuration. The Phase 1 baseline inventory is in progress as of this reply.
Three forward-looking architecture questions to inform the migration design, where your team's experience with similar workloads exceeds our local guesswork:
az staticwebapp functions link fully purge any managed-Functions deployment cache before the new Function App becomes authoritative, or is there state coupling we should plan around?We will report back with cutover confirmation and ≥5-day-stable parallel-run results, at which point this ticket can be closed. Thank you again for the substantive guidance — the explicit written recommendation has been valuable in scoping the migration internally.
Hi Pavani thanks for following up.
Your previous guidance was substantively helpful. We're adopting the BYOF long-term recommendation and have
scheduled the migration. In the interim, we're applying a dynamic property-access refactor to mitigate the stale-
binding symptom. The SKU toggle workaround was blocked by active Managed Identity (MI must be disabled before SKU change, which requires re-granting Key Vault access policies post- toggle) — worth noting for future customers in similar configurations. I'll post back to this thread once the BYOF migration is complete, in case it helps others encountering the same
managed Functions + MI + Key Vault references combination.
Thanks again for the engagement.
Update — sharper evidence after further diagnostics
This is a follow-up update to the original investigation in this thread. The original 4 ruled-out hypotheses (R1–R4) still hold; the new evidence below sharpens the open question substantially.
Two further workarounds attempted and empirically falsified: (a) trivial file-touch on the caller function file to change its file hash and force re-binding to the freshly-loaded shared module; (b) a full source-folder rename (e.g. api/ → api2/) plus matching workflow YAML update (api_location), to force the SWA managed Functions deploy pipeline to treat the deployment as a brand-new managed-functions registration. Both deployed cleanly. Both failed to resolve the symptom.
Four facts verified in App Insights for the latest attempt:
main deploy completion. The worker's "Initializing Warmup Extension" log timestamp is within seconds of the deploy run finishing. Confirmed via a new cloud_RoleInstance GUID. Fresh process, not warm-worker continuation.console.log at module-load time (line 1 of the shared module, outside any function body) appears in App Insights traces under the new worker's cloud_RoleInstance shortly after the warmup-init log. Node's require() returned new file contents to this process.INSERT that depends on a new permissions pattern from the same PR succeeds. The caller file is the new version.log('...entered v2') placed as the first executable statement inside the shared module's exported function — before any try/catch — is absent from App Insights, while logs from immediately before the call (in the caller) and immediately after the call (in the caller's empty-result branch) both fire normally. Under standard Node.js semantics this should not occur: if the function were called, the entry log must fire before any failure mode.The module-load layer is healthy: fresh workers reliably load the new shared module on every fresh deploy. The caller-binding layer is the active pathology: destructured function references inside caller files appear to remain bound to a pre-deploy version of the exported function even after a fresh worker process spawn that successfully reloads the shared module. PR-level workarounds that change the caller's file hash, the shared module's file hash, and even the entire source folder's path do not clear this binding.
Question for the SWA team: what platform mechanism caches the caller's function binding across what is otherwise a clean worker process restart with a fresh module load? Plausible candidates I cannot confirm without platform-internal visibility — @azure/functions handler registry capturing references at registration time; worker-pool pre-warming inheriting handler bindings from a parent process; or a managed-Functions deployment-pipeline layer caching function metadata above the Node process itself.
One configuration observation worth noting: az staticwebapp environment list shows several preview environments persisting in Ready status from old feature branches (some weeks old, source PRs closed). Each has its own distinct hostname so URL-level routing is not the concern. The open question is whether managed-Functions worker compute is isolated per-environment or shared across environments in a single SWA resource. If shared, function-handler bindings established by an earlier preview-environment deploy could conceivably persist into the production worker pool. I cannot test this from the customer side.
Happy to share full repro details — cloud_RoleInstance GUIDs, exact timestamps, full App Insights query results — privately via support channel for backend correlation.
AI answer
For Static Web Apps with managed Functions, the supported way to force new code to run is to ensure that:
From the available information, the following mechanisms and checks are supported.
Static Web Apps uses the Oryx build process and then validates the configured folders:
app_location – root of the frontend sourceoutput_location – build output folder under app_locationapi_location – root of the Azure Functions app for managed functionsIf these are misconfigured, SWA can successfully run the workflow while still serving older artifacts.
Actions:
app_location, output_location, and api_location match the repo layout and that the Functions app is under the configured api_location.If api_location is wrong or missing, the build may succeed but the live /api route continues to use the previous managed Functions app.
/apiFor SWA managed Functions:
/api route is fixed.api_location in the workflow.If api_location is changed or misaligned, SWA can end up with an older managed Functions app still serving /api while new builds are going to a different folder that is not wired to the live route.
Actions:
api_location in the workflow is stable and points to the same folder across all commits./api that might be serving an older backend.Application Insights is the supported way to see runtime behavior for both Static Web Apps and managed Functions:
/api endpoint.Actions:
If no new markers appear at all, this reinforces that the live Functions host is still using older artifacts or a different API backend.
The platform behavior for managed Functions in Static Web Apps is:
api_location content is expected to update the managed Functions app and cause the Functions host to load the new package.There is no separate restart/stop/start command for managed Functions; the refresh is tied to the SWA deployment itself. The documented mechanisms to influence runtime behavior are:
Given the symptoms (successful builds, old code executing), the most actionable steps supported by the documentation are:
app_location, output_location, and especially api_location are correct for the repo.output_location is actually produced by the build (for example, the folder exists after npm run build).If, after confirming folder configuration and redeploying, the Functions host still serves old code, this becomes a platform-side issue that requires Azure support to inspect the SWA’s internal deployment state. The public documentation does not expose an additional CLI/portal “force refresh” operation beyond correcting configuration and redeploying.
There is no documented guidance that scaling between Free and Standard, or detaching/reattaching Functions, is required or supported as a normal mechanism to force managed Functions to pick up new code.
References: