Static web apps and scheduled functions

forestfire 41 Reputation points
2021-07-15T17:47:04.113+00:00

Hello there, I am trying to develop a static web app that displays fantasy sports stats. One issue that i have run into is what the best way to automatically have my api functions called on a scheduler. I would like this to happen so i can get the latest stats and not have to manually refresh everytime i want it to run. Is there a way to implement a scheduler for azure static web apps?

Thank you

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
36,258 questions
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
770 questions
0 comments No comments
{count} votes

Accepted answer
  1. Grmacjon-MSFT 16,191 Reputation points
    2021-07-16T01:26:21.57+00:00

    Hi @forestfire ,

    Thanks for using Microsoft Q&A!

    Yes, I believe your scenario is possible using the new Static Web app feature (Bring your own functions to Azure Static Web Apps) . You can create a scheduler using Azure Functions and connect it to Azure static web app by following the below steps. Keep in mind Bring your own functions (BYOF) is only available in the Azure Static Web Apps Standard plan.

    Consider an existing Azure Functions app that exposes an endpoint via the following location.

    https://my-functions-app.azurewebsites.net/api/getProducts  
    

    Once linked, you can access that same endpoint through the api path from your static web app, as shown in this example URL.

    https://red-sea-123.azurestaticapps.net/api/getProducts  
    

    Both endpoint URLs point to the same function.

    Set-up steps in Azure portal:

    Before you associate an existing Functions app, you first need to adjust to configuration of your static web app.

    1. Set api_location value to an empty string ("") in the workflow configuration file. Make sure to set the api_location value to an empty string ("") in the workflow configuration file before you link an existing Functions application.
    2. Open your Static Web Apps instance in the Azure portal.
    3. From the Settings menu, select Functions.
    4. From the Environment dropdown, select Production.
    5. Next to the Functions source label, select Link to a Function app.
    6. From the Subscription dropdown, select your Azure subscription name.
    7. From the Function App dropdown, select the name of the existing Functions app you want to link to your static web app.
    8. Select the Link button.

    Hope that helps. Please let us know if you have further questions.

    Best,
    Grace

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful