Deployed Static Web Apps (Preview) API Functions not working

ngtdev 11 Reputation points
2020-10-20T22:22:23.077+00:00

Hi there!

I have had an Azure Static Web App set up for some time now, and have recently added some functions to interact with a 3rd party API, following the instructions given here: https://learn.microsoft.com/en-us/azure/static-web-apps/add-api

The app deploys fine, with no warnings. I have set up the configuration variables and re-deployed. Yet when I load my app, any call to a function (via fetch) results in a 500 error.

The SWA's Functions section does display the functions, however there is nothing but a list, nothing to interact with or links to logs, etc.

33802-screen-shot-2020-10-20-at-61408-pm.png

I've also checked to see if there is a Functions App created, however there is nothing.

My workflow file is configured like so:

   app_location: "/" # App source code path  
   api_location: "api" # Api source code path - optional  

Some logs here would be helpful, but I've not found how to access logs for these functions. How would I do so?

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,173 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Ryan Hill 30,281 Reputation points Microsoft Employee Moderator
    2020-10-23T17:57:08.853+00:00

    Hi @ngtdev ,

    For the now, the current guidance is to leverage Application Insights for logging. We do have an open github issue to track discussion and improvements; feel free to engage in the discussion. Inside that issue, there's a reference to https://www.aaron-powell.com/posts/2020-08-12-getting-logs-from-static-web-apps-apis/ which is a step-by-step guide to using Application Insights in your static web app.

    Regards,
    Ryan

    0 comments No comments

  2. Joseph Jobbings 96 Reputation points
    2021-05-11T09:53:38.513+00:00

    @ngtdev hi I noticed this thread as I am browsing for any explanation as to why our Azure Functions in SWAs have "disappeared" today (i.e. no longer showing in azure SWA admin console).

    We also struggled to figure out how to view Functions app trace/ log entries deployed to Azure SWA but we stumbled upon the link @Ryan Hill added above - and followed that, creating a Log workspace initially in Azure and linking that to App Insights and eventually adding an instrumentation key to our Functions. The log messages sometimes didn't appear (or took a long time to appear, perhaps I was just too impatient!).

    I see since 23rd April of this year (?) there is now an 'Application Insights' option in SWA. @Ryan Hill do you know if that config option is a new feature and does it mean we don't need to add instrumentation_key any more to see Functions tracing in App Insight logs?

    0 comments No comments

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.