Azure Static Web App not getting response from static web api API Function

Travis Kool 1 Reputation point
2022-12-22T21:18:35.21+00:00

I Currently have a static web app deployed in Azure which is operating fine, however, I am seeing issues with the app making requests to the "API" Azure Function App.

Currently my Azure Function App is on the Api folder in the root of my GitHub repo, next to my Blazor static web app.

When i set the YAML app_location to API, then it properly locates my Azure Function and it displays as Managed in the APIs tab of my Azure Static Web App. However, when the web app makes the request to the function, it shows as pending and eventually after 45 seconds, returns with a 500 error.

I since have read that app_location needs to be set to empty string, so I have done made this YAML adjustment in github, though, now the APIs tab does not show any managed function and when my static blazor app makes an http request to the function, it returns with 502 error immediately...

502 - Web server received an invalid response while acting as a gateway or proxy server.

Will you please advise on

  1. Is the Azure Functions project OK to be in API folder within the root of my repo?
  2. Why is there no response from the function when i set the app_location to API, but the static web app service in Azure has located my managed function ?

EDIT: Sometimes the backend call is "Pending" then returns a 500 with message "Backend call failure"

Keep in mind all of this works on my local :)

Thanks,
Travis

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
320 questions
No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Travis Kool 1 Reputation point
    2022-12-23T02:38:56.587+00:00

    UPDATE - Resolved

    After enabling App Insights / Logging , it was clear that the static web app did not have permission to access AzureSql.

    Fetching Events - Failed: $Cannot open server 'redacted' requested by the login. Client with IP address '52.191.132.158' is not allowed to access the server. To enable access, use the Windows Azure Management Portal or run sp_set_firewall_rule on the master database to create a firewall rule for this IP address or address range. It may take up to five minutes for this change to take effect.

    After whitelisting the Static Web App IP, the problem is resolved.

    Are static web app IP's "Static" as in they won't change?

    No comments