Azure Static Web App returns HTTP 500 for /api/ with linked Azure Function App, but direct Function invocation succeeds*

Avula Satish Kumar 0 Reputation points
2026-12-01T14:34:17.26+00:00

Hi Team,

We are experiencing HTTP 500 Internal Server Error when calling /api/* endpoints through an Azure Static Web App linked to an existing Azure Function App.

Architecture:

  • Angular frontend deployed to Azure Static Web Apps
  • Separate Node.js Azure Function App
  • Existing Function App linked through Static Web App → APIs
  • Backend Function calls a downstream REST API

Observed behavior:

  1. Calling /api/chart-data/run through the production Static Web App returns HTTP 500 with an empty response body.
  2. Calling the same Function directly from inside its runtime container using localhost returns HTTP 200 with the expected data.
  3. The Function App can successfully call the downstream REST API.
  4. The Function Host reports Running, and the HTTP routes are registered.
  5. The equivalent development Static Web App works correctly.
  6. Unlinking and relinking the Function App, restarting, and redeploying have not resolved the issue.
  7. The error persists when accessing the Static Web App directly, bypassing the external gateway.

Question:

What could cause Azure Static Web Apps to return HTTP 500 when forwarding /api/* requests to a linked Function App, even though the Function itself works when invoked directly?

Are there specific backend integration, authentication, networking, or diagnostic logs we should check?

Any guidance would be appreciated.Hi Team,

We are experiencing HTTP 500 Internal Server Error when calling /api/* endpoints through an Azure Static Web App linked to an existing Azure Function App.

Architecture:

  • Angular frontend deployed to Azure Static Web Apps
  • Separate Node.js Azure Function App
  • Existing Function App linked through Static Web App → APIs
  • Backend Function calls a downstream REST API

Observed behavior:

  1. Calling /api/chart-data/run through the production Static Web App returns HTTP 500 with an empty response body.
  2. Calling the same Function directly from inside its runtime container using localhost returns HTTP 200 with the expected data.
  3. The Function App can successfully call the downstream REST API.
  4. The Function Host reports Running, and the HTTP routes are registered.
  5. The equivalent development Static Web App works correctly.
  6. Unlinking and relinking the Function App, restarting, and redeploying have not resolved the issue.
  7. The error persists when accessing the Static Web App directly, bypassing the external gateway.

Question:

What could cause Azure Static Web Apps to return HTTP 500 when forwarding /api/* requests to a linked Function App, even though the Function itself works when invoked directly?

Are there specific backend integration, authentication, networking, or diagnostic logs we should check?

Any guidance would be appreciated.

Azure Functions
Azure Functions

An Azure service that provides an event-driven serverless compute platform.

0 comments No comments

1 answer

Sort by: Most helpful
  1. AI answer

    2026-12-01T14:35:34.65+00:00

    The production Function App must expose the identical /api/chart-data/run route publicly to the Static Web Apps proxy, with no Function App IP restriction, private endpoint, or service endpoint blocking that proxy.

    A successful localhost call proves that the worker and downstream dependency function inside the container, but it does not test the Static Web Apps-to-Function App authentication, routing, or network boundary. Since restarting, redeploying, and relinking did not help, use the checks below rather than repeating them.

    1. Validate the linked-backend contract

    Check each production-specific requirement:

    1. Static Web Apps plan and environment
      • The Static Web App must use the Standard plan.
      • The Function App must be linked to the Production environment under Static Web App → Settings → APIs.
      • Existing backend integration is not supported for pull-request environments. ^1^
    2. Disable managed-function deployment
      • Open the production Static Web Apps workflow YAML under .github/workflows.
      • Set:
             api_location: ""
        
      • A Static Web App environment supports only one backend type, so the workflow must not also deploy managed Functions. ^1^
    3. Preserve the /api prefix
      • Inspect the Function App’s deployed host.json.
      • Static Web Apps forwards /api/chart-data/run as that same path. The external Function App therefore must expose /api/chart-data/run, not /chart-data/run.
      • If host.json removes or changes extensions.http.routePrefix, restore the default api prefix or otherwise ensure the deployed endpoint is exactly /api/chart-data/run. ^1^
    4. Confirm the selected production slot
      • In Static Web App → APIs, verify that the linked resource and Backend slot are the intended production Function App and slot.
      • Compare these values with the working development Static Web App. Differences here are more significant than the Angular deployment because /api requests are reverse-proxied to the configured backend. ^2^

    2. Check the Function App ingress boundary

    Under Function App → Networking, check whether production has any of these:

    • Inbound IP access restrictions
    • A private endpoint
    • Traffic restricted through service endpoints

    A linked existing Function App must remain publicly accessible and cannot use those restrictions for this integration. Remove the restriction temporarily for a controlled test; if the request then succeeds, redesign the ingress boundary rather than repeatedly relinking it. ^1^

    A private endpoint on the Static Web App itself is a different mechanism: requests arriving there from a public IP normally return 403, not this empty 500. ^3^

    3. Check authentication and Function authorization

    Linking creates an identity provider named Azure Static Web Apps (Linked) on the Function App. If Function App authentication is enabled:

    • It must use App Service Authentication version 2.
    • In Function App → Settings → Authentication, verify that the linked provider is present and that no production-only authentication policy rejects the proxied identity.
    • Compare the Authentication blade with the working development Function App/link. ^1^

    Also inspect the HTTP trigger’s authorization level:

    • If it is function or admin, the request must contain an access key.
    • For a browser call through /api, either provide the required key as designed or use anonymous authorization and enforce access through Static Web Apps/App Service authentication instead. Functions require a key unless the trigger’s HTTP access level is anonymous. ^4^

    Do not delete the linked identity provider merely as a diagnostic step; that changes the security model and can expose the Function App to anonymous traffic.

    4. Determine whether the proxy reached the Function

    For bring-your-own Functions, enable Application Insights on the Function App, not only on Static Web Apps. ^5^

    Reproduce one failed request, record its UTC timestamp, then run:

    requests
    | where timestamp > ago(30m)
    | where url contains "/api/chart-data/run"
    | project timestamp, name, resultCode, success, operation_Id, url
    | order by timestamp desc
    

    Then inspect correlated exceptions:

    exceptions
    | where timestamp > ago(30m)
    | project timestamp, operation_Id, type, outerMessage
    | order by timestamp desc
    

    Interpret the result:

    • No request row: the call did not reach the Functions runtime. Concentrate on the linked resource/slot, /api route, authentication provider, access key, and inbound networking.
    • Request row with 500: the Function was invoked through the proxy. Filter traces and exceptions by its operation_Id; compare headers, identity data, configuration, and code paths against the localhost invocation.
    • Request row with 200, while the client receives 500: collect the UTC timestamp, Static Web App hostname, Function App/slot, operation_Id, and response headers, then open an Azure support case for the Static Web Apps integration layer.

    Application Insights requires at least Contributor on the Function App and Monitoring Reader on the Application Insights resource; telemetry can take up to five minutes to appear. ^6^

    Also run:

    • Static Web App → Diagnose and solve problems → Availability and performance
    • Static Web App → Diagnose and solve problems → Configuration and Management
    • Function App → Diagnose and solve problems → Function App Down or Reporting Errors (Preview)

    The latter checks runtime, deployment, configuration, storage, identity, networking, and execution failures. ^7^


    References

    1. Bring your own functions to Azure Static Web Apps
    2. Overview of API support in Azure Static Web Apps
    3. Configure private endpoint in Azure Static Web Apps
    4. Securing Azure Functions
    5. API support in Azure Static Web Apps with Azure Functions
    6. Analyze Azure Functions telemetry in Application Insights
    7. Troubleshoot Azure Functions app down or reporting errors
    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.