API support in Azure Static Web Apps with Azure App Service

Azure App Service is a managed platform for hosting web applications that execute code on servers. Azure App Service supports many runtimes and frameworks including Node.js, ASP.NET Core, PHP, Java, and Python.

When you link your Azure App Service web app to your static web app, any requests to your static web app with a route that starts with /api are proxied to the same route on the Azure App Service app.

By default, when an App Service app is linked to a static web app, the App Service app only accepts requests that are proxied through the linked static web app. An Azure App Service app can only be linked to a single static web app at a time.

All Azure App Service hosting plans are available for use with Azure Static Web Apps.

API options for Static Web Apps include the following Azure services:

See the APIs overview for more information.

Note

The integration with Azure App Service is currently in preview and requires the Static Web Apps Standard plan.

You cannot link a web app to a Static Web Apps pull request environment.

To link a web app as the API backend for a static web app, follow these steps:

  1. In the Azure portal, go to the static web app.

  2. Select APIs from the navigation menu.

  3. Locate the environment you want to link the API Management instance to. Select Link.

  4. In Backend resource type, select Web App.

  5. In Subscription, select the subscription containing the Azure App Service app you want to link.

  6. In Resource name, select the Azure App Service app.

  7. Select Link.

When the linking process is complete, requests to routes beginning with /api are proxied to the linked App Service app.

Manage access to Azure App Service

Your App Service app is configured with an identity provider named Azure Static Web Apps (Linked) that permits only traffic that is proxied through the static web app. To make your App Service app accessible to other applications, update its authentication configuration to add another identity provider or change the security settings to allow unauthenticated access.

To unlink a web app from a static web app, follow these steps:

  1. In the Azure portal, go to the static web app.

  2. Select APIs from the navigation menu.

  3. Locate the environment that you want to unlink and select the web app name.

  4. Select Unlink.

When the unlinking process is complete, requests to routes beginning with /api are no longer proxied to your App Service app.

Note

To prevent accidentally exposing your App Service app to anonymous traffic, the identity provider created by the linking process is not automatically deleted. You can delete the identity provider named Azure Static Web Apps (Linked) from the App Service app's authentication settings.

Next steps