API support in Azure Static Web Apps with Azure Container Apps

Azure Container Apps is a managed platform for hosting serverless containers and microservices.

When you link your container 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 container app.

By default, when a container app is linked to a static web app, the container app only accepts requests that are proxied through the linked static web app. A container app can be linked to a single static web app at a time.

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

See the APIs overview for more information.

Note

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

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

To link a container 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 Container App.

  5. In Subscription, select the subscription containing the container app you want to link.

  6. In Resource name, select the container app.

  7. Select Link.

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

Manage access to the container app

Your container 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 container 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 container 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 container app name.

  4. Select Unlink.

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

Note

To prevent accidentally exposing your container 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 container app's authentication settings.

Next steps