Azure Static Web Apps Introduces API Backend Options

Azure-Static-Web-Apps-Introduces-API-Backend-Options

Static Web Apps (SWA) is an Azure service that automatically builds and deploys full-stack web apps directly from a code repository, with GitHub and AzureDevOps integration

Azure recently announced the preview of new API backend options in Azure Static Web Apps. Developers can now create an end-to-end authenticated application calling APIs hosted on Azure App Service, Azure Container Apps, or Azure API Management.

Static Web Apps (SWA) is an Azure service that automatically builds and deploys full-stack web apps directly from a code repository, with GitHub and AzureDevOps integration. A common requirement of web applications is to call backend APIs for data and services, and the SWA APIs functionality provides integrated security with direct access to user authentication and role-based authorisation data.

“You can link these resources to your static web app’s production or preview environments. Any requests to a route prefixed with /API are routed to your backend resource when linked. Using a linked backend allows your frontend app to call your API without configuring cross-origin resource sharing (CORS), and it enables Static Web Apps Authentication to work seamlessly and securely with your API,” said  Annina Keller, Software Engineer, Microsoft.

SWA was already integrated with Azure Functions, allowing developers to deploy an API with the static web app without managing a separate Azure Functions resource. The new options support instead a “bring your own APIs” scenario, integrating a static web application with existing APIs hosted on other Azure services.

App Service can be used to host APIs built with frameworks like Flask, Express, Apollo, and ASP.NET, Container Apps to integrate with APIs and microservices running in serverless containers and API Management to multiple aggregate APIs in a unified API gateway.

The cloud provider released best practices for SWA and a recording on how to use the SWA CLI. Among the current limitations of the new backend options, each static web app environment can only be configured with one type of backend API at a time, the API route prefix must be /API, WebSocket is not supported (HTTP only), and the maximum duration of each request is 45 seconds.