404 static web app azure function TS

Christopher Moskovitz 0 Reputation points
2023-05-23T19:35:42.0066667+00:00

I am using Azure static web app and managed azure function. This is an angular app. swa build and build and deploy works fine. Everything shows success and I can but the endpoints locally. However when I deploy with the cli or with git hub actions and I hit the endpoints via UI on /app/myFunction I get 404 not found. Just azure functions are not being hit.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,173 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Artem Smirnov 30 Reputation points
    2023-12-11T11:26:30.0833333+00:00

    I've just spent several hours trying to fix it. Turned out I had a wrong import at the top of one of my api files. When Azure runs all files to register the handlers, any error before the app.http call stops the process and none of the other handlers are registered.

    2 people found this answer helpful.

  2. Amy Kline 75 Reputation points
    2023-05-23T20:01:22.12+00:00

    To resolve the 404 error you're encountering when accessing Azure Functions in your Angular app deployed as an Azure Static Web App, follow these steps:

    1. Verify Function App deployment and configuration.
    2. Check the routing configuration in your Angular app.
    3. Ensure the base URL for Azure Functions is correct.
    4. Validate Azure Static Web App configuration.
    5. Check deployment logs for errors or warnings.
    6. Verify access restrictions or authentication settings.
    7. Test Azure Functions locally to isolate the issue.
    8. Review Azure Function logs for errors.

    By following these steps, you can troubleshoot and resolve the issue causing the 404 error.

    0 comments No comments

  3. Ryan Hill 30,281 Reputation points Microsoft Employee Moderator
    2023-05-23T21:33:01.1833333+00:00

    @Christopher Moskovitz

    Managed API defaults to /api/functionname. The platform will automatically forward requests to that endpoint. If you're getting 404s, the only thing I can think of is your you never updated the output dir for your deployment.

    Using swa cli, this is the --api-location argument. In yaml, it's the api_location argument. Try http repl to https://<swa-host-name>.staticwebapps.net/api/functionname to call the endpoint directly to confirm.


Your answer

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