Share via

Static Web App BYO backend returns HTML 500 before Function execution (invocations stay 0)

Lionel Lapidos 0 Reputation points
2026-02-23T17:06:47.8666667+00:00

We have a production Azure Static Web App with a linked Azure Function App backend.

Current behavior:

  • User sign-in works normally.
  • /.auth/me returns a valid clientPrincipal.
  • API calls from the Static Web App fail with HTTP 500 and content-type: text/html (not JSON):
    • GET /api/v1/charts?limit=1
    • GET /api/v1/admin/users
    • POST /api/v1/charts
  • x-correlation-id is null on these responses.
  • Function App Monitor shows no invocation increase for the corresponding functions (stays at 0).

Expected behavior:

  • Requests should reach the linked Function App and return JSON (including function-level errors), with invocation

telemetry.

Already tried:

  • Created a new Static Web App and deployed successfully.
  • Linked backend to Function App.
  • Confirmed CI/CD workflow and deployment token for the new SWA.
  • Confirmed Function App auth integration with Azure Static Web Apps (Linked).
  • Same issue reproduced across two SWA resources.

Impact:

  • Editors/admins cannot create charts; production workflow is blocked.
  • Need guidance to diagnose/repair SWA -> linked backend forwarding path.
Azure Static Web Apps
Azure Static Web Apps

An Azure service that provides streamlined full-stack web app development.


2 answers

Sort by: Most helpful
  1. Golla Venkata Pavani 5,390 Reputation points Microsoft External Staff Moderator
    2026-02-23T17:52:32.0333333+00:00

    Hi @Lionel Lapidos ,

    Thank you for the detailed investigation and for sharing the resolution.

    The HTTP 500 errors from the Azure Static Web App (SWA) BYO backend were caused by three combined infrastructure issues:

    NAT Gateway had no Public IP

    The Function App was using VNet integration with a NAT Gateway, but the NAT Gateway had no Public IP assigned. This blocked all outbound internet traffic, causing Easy Auth token validation to silently fail before the function code executed, resulting in 0 invocations and SWA 500 errors.

    Recommendation: Assigned a Standard Public IP to the NAT Gateway to restore outbound connectivity.

    Database IP Not Whitelisted

    After outbound connectivity was restored, function executions failed due to:

    YAML

    MongoServerSelectionError:
    

    The NAT Gateway’s Public IP was not added to MongoDB Atlas IP Access List.

    Recommendation: Whitelisted the NAT Gateway Public IP in MongoDB Atlas.

    Function App Linked to Wrong SWA

    The Function App backend was linked to a test SWA instance instead of production. Since a Function App can only be linked to one SWA at a time, the production SWA had no backend and returned SWA-level errors.

    Recommendation : Unlinked from test SWA and relinked to the correct production SWA.

    Kindly let us know if the above comment helps or you need further assistance on this issue.

    Could you  Please click "Accept the answer” and Yes, this can be beneficial to other community members.

    If you have any other questions, let me know in the "comments" and I would be happy to help you

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

  2. AI answer

    2026-02-23T17:07:00.13+00:00

    It seems that your Azure Static Web App (SWA) is not properly forwarding requests to the linked Azure Function App, resulting in HTTP 500 errors without any invocation increase. Here are some steps you can take to diagnose and potentially resolve the issue:

    1. Check API Location Configuration: Ensure that the api_location in your SWA configuration is correctly pointing to the root folder of your Azure Functions application, typically named api. If this is misconfigured, the requests may not reach the Function App.
    2. Review Application Insights: If you have Application Insights set up, check for any runtime error messages that may provide more context on the issue. You can find these by navigating to your Application Insights instance in the Azure portal and looking under the Failures section.
    3. Validate Deployment Logs: Review the deployment logs in your GitHub Actions for any errors or warnings that might indicate issues with the build or deployment process. Ensure that the deployment workflow is correctly configured to include the necessary API endpoints.
    4. Function App Authentication: Since you've confirmed that the Function App auth integration is linked, double-check that the authentication settings are correctly configured to allow requests from your SWA. This includes ensuring that the authentication tokens are being passed correctly.
    5. Test Directly Against Function App: As a troubleshooting step, try calling the Function App endpoints directly (bypassing the SWA) to see if they respond correctly. This can help determine if the issue is with the Function App itself or the forwarding from the SWA.
    6. Inspect CORS Settings: Ensure that the CORS settings on the Function App allow requests from your SWA domain, as restrictive CORS settings can lead to failed requests.

    If the issue persists after these checks, consider reaching out to Azure support for further assistance, as they can provide more detailed diagnostics specific to your environment.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.