An Azure service that provides streamlined full-stack web app development.
@Paris Perlegkas did you resolve you issue? were you able to get the endpoint api/GetRoles work?
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
We use Microsoft Entra External ID (CIAM) via a custom OpenID Connect provider (aadb2c) in Azure Static Web Apps authentication, with rolesSource configured to POST /api/GetRoles.
Issue:
Production sign-in fails with ERR_TOO_MANY_REDIRECTS. We traced it to rolesSource not being reachable through SWA because SWA is not routing /api/* to the linked Function App backend. Any request to /api/* returns the Azure Static Web Apps 404 Not Found HTML page, indicating the request is not forwarded to the backend.
Symptoms / Repro steps:
This confirms the function exists and works.
Impact:
Environment / configuration:
Question for support:
Microsoft documentation for SWA APIs/Functions lists supported Function App hosting plans for APIs as Consumption/Premium/Dedicated (Flex Consumption is not mentioned).
Requested outcome:
An Azure service that provides streamlined full-stack web app development.
@Paris Perlegkas did you resolve you issue? were you able to get the endpoint api/GetRoles work?
I have the same issue as the post. I'm using External Entra tenant, static web app, linked to bring-your-own azure function, and api/GetRoles to return the role assignment.
I have another api endpoint which is reachable by static web app via /api/test_api. It's hosted under the same Azure function, but the api/GetRoles endpoint is not called at all during the static web app sign in process. I don't see any errors in browser network or console, the Azure function logging shows no invocation for api/GetRoles.
I'm very stuck with this whole infra. Any help?
Hi @Paris Perlegkas
It seems like you're having trouble with your Azure Static Web App not routing API requests to your Azure Function App.
Make sure your staticwebapp.config.json is set up properly. Since /api/* requires authentication, confirm your route rules allow access.
{
"routes": [
{
"route": "/api/*",
"allowedRoles": ["authenticated"]
}
]
}
If your function works directly but not through the Static Web App, check the authentication settings on your Function App. Sometimes these settings can prevent requests from being routed correctly.
In the Azure portal, verify that your Static Web App is linked to the right Function App without any errors under the "APIs" section.
The Flex Consumption plan isn’t specifically listed as compatible with Azure Static Web Apps linked backends. If it worked before, there might have been a configuration change. You might want to try the standard Consumption or Premium plan instead.
Create a simple test function like /api/test that returns a basic JSON response. This can help you see if the Static Web App can access any function in your linked Function App.
https://learn.microsoft.com/en-us/azure/static-web-apps/authentication-authorization?tabs=invitations
https://learn.microsoft.com/en-us/azure/static-web-apps/apis-overview?wt.mc_id=knowledgesearch_inproduct_azure-cxp-community-insider
Let me know if you have any further assistances needed.
AI answer
The issue you're experiencing with Azure Static Web Apps (SWA) not routing /api/* requests to your linked Azure Function App could be related to the configuration of your SWA and the specifics of the Function App hosting plan.
staticwebapp.config.json is correctly configured to route /api/* requests to the linked Function App. The api_location should be set to an empty string ("") when using a linked backend, which you mentioned is already done. Additionally, verify that the Function App is indeed linked correctly in the Azure portal./api/* are returning a 404 error, it may be useful to check the following:
To resolve the routing issue, you may need to ensure that the Function App is configured correctly and that there are no restrictions preventing the SWA from accessing it. If the problem persists, contacting Azure support would be advisable for further investigation.
References: