You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/static-web-apps/add-api.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ ms.custom: devx-track-js
15
15
You can add serverless APIs to Azure Static Web Apps that are powered by Azure Functions. This article demonstrates how to add and deploy an API to an Azure Static Web Apps site.
16
16
17
17
> [!NOTE]
18
-
> The functions provided by default in Static Web Apps are pre-configured to provide secure API endpoints and only support HTTP-triggered functions. See [API support with Azure Functions](apis.md) for information on how they differ from standalone Azure Functions apps.
18
+
> The functions provided by default in Static Web Apps are pre-configured to provide secure API endpoints and only support HTTP-triggered functions. See [API support with Azure Functions](apis-functions.md) for information on how they differ from standalone Azure Functions apps.
title: API support in Azure Static Web Apps with Azure API Management
3
+
description: Learn how to use Azure API Management with Azure Static Web Apps
4
+
services: static-web-apps
5
+
author: craigshoemaker
6
+
ms.service: static-web-apps
7
+
ms.topic: conceptual
8
+
ms.date: 06/14/2022
9
+
ms.author: cshoe
10
+
---
11
+
12
+
# API support in Azure Static Web Apps with Azure API Management
13
+
14
+
[Azure API Management](../api-management/api-management-key-concepts.md) is a service that allows you to create a modern API gateway for existing back end services.
15
+
16
+
When you link your Azure API Management service 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 in the Azure API Management service.
17
+
18
+
An Azure API Management service can be linked to multiple static web apps at the same time. An API Management product is created for each linked static web app. Any APIs added to the product is available to the associated static web app.
19
+
20
+
All Azure API Management pricing tiers are available for use with Azure Static Web Apps.
> The integration with Azure API Management is currently in preview and requires the Static Web Apps Standard plan.
26
+
>
27
+
> Currently, you cannot link an API Management service to a Static Web Apps [pull request environment](review-publish-pull-requests.md).
28
+
29
+
## Link an Azure API Management service
30
+
31
+
To link an Azure API Management service as the API backend for a static web app, follow these steps:
32
+
33
+
1. In the Azure portal, navigate to the static web app.
34
+
35
+
1. Select **APIs** from the navigation menu.
36
+
37
+
1. Locate the environment you want to link the API Management service to. Select **Link**.
38
+
39
+
1. In *Backend resource type*, select **API Management**.
40
+
41
+
1. In *Subscription*, select the subscription containing the Azure API Management service you want to link.
42
+
43
+
1. In *Resource name*, select the Azure API Management service.
44
+
45
+
1. Select **Link**.
46
+
47
+
When the linking process is complete, requests to routes beginning with `/api` are proxied to your Azure API Management service. However, no APIs are exposed by default. See [Manage access to APIs](#manage-access-to-apis) to configure an API Management product to allow the APIs you want to use.
48
+
49
+
### Manage access to APIs
50
+
51
+
Azure API Management has a *products* feature that defines how APIs are surfaced. As part of the linking process, your API Management service is configured with a product named `Azure Static Web Apps - <STATIC_WEB_APP_AUTO_GENERATED_HOSTNAME> (Linked)`.
52
+
53
+
Because no APIs are associated with the new API Management product, accessing a `/api` route in your static web app returns the following error from API management.
54
+
55
+
```json
56
+
{
57
+
"statusCode": 401,
58
+
"message": "Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription."
59
+
}
60
+
```
61
+
62
+
To make APIs available to your linked static web app, [add them to the product](../api-management/api-management-howto-add-products.md#add-apis-to-a-product).
63
+
64
+
The linking process also automatically applies the following configuration to your API Management service:
65
+
66
+
* The product associated with the linked static web app is configured to require a subscription.
67
+
* An API Management subscription named `Generated for Static Web Apps resource with default hostname: <STATIC_WEB_APP_AUTO_GENERATED_HOSTNAME>` is created and scoped to the product with the same name.
68
+
* An inbound *validate-jwt* policy is added to the product to allow only requests that contain a valid access token from the linked static web app.
69
+
* The linked static web app is configured to include the subscription's primary key and a valid access token when proxying requests to the API Management service.
70
+
71
+
> [!IMPORTANT]
72
+
> Changing the *validate-jwt* policy or regenerating the subscription's primary key will prevent your static web app from proxying requests to the API Management service. Do not modify or delete the subscription or product associated with your static web app while they are linked.
73
+
74
+
## Unlink an Azure API Management service
75
+
76
+
To unlink an Azure API Management service from a static web app, follow these steps:
77
+
78
+
1. In the Azure portal, navigate to the static web app.
79
+
80
+
1. Locate the environment that you want to unlink and select the API Management service name.
81
+
82
+
1. Select **Unlink**.
83
+
84
+
When the unlinking process is complete, requests to routes beginning with `/api/` are no longer proxied to your API Management service.
85
+
86
+
> [!NOTE]
87
+
> The API Management product and subscription associated with the linked static web app are not automatically deleted. You can delete them from the API Management service.
title: API support in Azure Static Web Apps with Azure App Service
3
+
description: Learn how to use Azure App Service with Azure Static Web Apps
4
+
services: static-web-apps
5
+
author: craigshoemaker
6
+
ms.service: static-web-apps
7
+
ms.topic: conceptual
8
+
ms.date: 06/14/2022
9
+
ms.author: cshoe
10
+
---
11
+
12
+
# API support in Azure Static Web Apps with Azure App Service
13
+
14
+
[Azure App Service](../app-service/overview.md) 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.
15
+
16
+
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.
17
+
18
+
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.
19
+
20
+
All Azure App Service hosting plans are available for use with Azure Static Web Apps.
> The integration with Azure API Management is currently in preview and requires the Static Web Apps Standard plan.
26
+
>
27
+
> You cannot link a web app to a Static Web Apps [pull request environment](review-publish-pull-requests.md).
28
+
29
+
## Link an Azure App Service Web App
30
+
31
+
To link a web app as the API backend for a static web app, follow these steps:
32
+
33
+
1. In the Azure portal, navigate to the static web app.
34
+
35
+
1. Select **APIs** from the navigation menu.
36
+
37
+
1. Locate the environment you want to link the API Management instance to. Select **Link**.
38
+
39
+
1. In *Backend resource type*, select **Web App**.
40
+
41
+
1. In *Subscription*, select the subscription containing the Azure App Service app you want to link.
42
+
43
+
1. In *Resource name*, select the Azure App Service app.
44
+
45
+
1. Select **Link**.
46
+
47
+
When the linking process is complete, requests to routes beginning with `/api` are proxied to the linked App Service app.
48
+
49
+
### Manage access to Azure App Service
50
+
51
+
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.
52
+
53
+
## Unlink an Azure App Service app
54
+
55
+
To unlink a web app from a static web app, follow these steps:
56
+
57
+
1. In the Azure portal, navigate to the static web app.
58
+
59
+
1. Select **APIs** from the navigation menu.
60
+
61
+
1. Locate the environment that you want to unlink and select the web app name.
62
+
63
+
1. Select **Unlink**.
64
+
65
+
When the unlinking process is complete, requests to routes beginning with `/api` are no longer proxied to your App Service app.
66
+
67
+
> [!NOTE]
68
+
> 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.
title: API support in Azure Static Web Apps with Azure Container Apps
3
+
description: Learn how to use Azure Container Apps with Azure Static Web Apps
4
+
services: static-web-apps
5
+
author: craigshoemaker
6
+
ms.service: static-web-apps
7
+
ms.topic: conceptual
8
+
ms.date: 06/14/2022
9
+
ms.author: cshoe
10
+
---
11
+
12
+
# API support in Azure Static Web Apps with Azure Container Apps
13
+
14
+
[Azure Container Apps](../container-apps/overview.md) is a managed platform for hosting serverless containers and microservices.
15
+
16
+
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.
17
+
18
+
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.
> The integration with Azure Container Apps is currently in preview and requires the Static Web Apps Standard plan.
24
+
>
25
+
> You cannot link a container app to a Static Web Apps [pull request environment](review-publish-pull-requests.md).
26
+
27
+
## Link a container app
28
+
29
+
To link a web app as the API backend for a static web app, follow these steps:
30
+
31
+
1. In the Azure portal, navigate to the static web app.
32
+
33
+
1. Select **APIs** from the navigation menu.
34
+
35
+
1. Locate the environment you want to link the API Management instance to. Select **Link**.
36
+
37
+
1. In *Backend resource type*, select **Container App**.
38
+
39
+
1. In *Subscription*, select the subscription containing the container app you want to link.
40
+
41
+
1. In *Resource name*, select the container app.
42
+
43
+
1. Select **Link**.
44
+
45
+
When the linking process is complete, requests to routes beginning with `/api` are proxied to the linked container app.
46
+
47
+
### Manage access to the container app
48
+
49
+
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.
50
+
51
+
## Unlink a container app
52
+
53
+
To unlink a container app from a static web app, follow these steps:
54
+
55
+
1. In the Azure portal, navigate to the static web app.
56
+
57
+
1. Select **APIs** from the navigation menu.
58
+
59
+
1. Locate the environment that you want to unlink and select the container app name.
60
+
61
+
1. Select **Unlink**.
62
+
63
+
When the unlinking process is complete, requests to routes beginning with `/api` are no longer proxied to your container app.
64
+
65
+
> [!NOTE]
66
+
> 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.
Copy file name to clipboardExpand all lines: articles/static-web-apps/apis-functions.md
+15-17Lines changed: 15 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,19 @@
1
1
---
2
2
title: API support in Azure Static Web Apps with Azure Functions
3
-
description: Learn what API features Azure Static Web Apps supports
3
+
description: Learn how to use Azure Functions with Azure Static Web Apps
4
4
services: static-web-apps
5
5
author: craigshoemaker
6
6
ms.service: static-web-apps
7
7
ms.topic: conceptual
8
-
ms.date: 03/29/2022
8
+
ms.date: 06/14/2022
9
9
ms.author: cshoe
10
10
---
11
11
12
12
# API support in Azure Static Web Apps with Azure Functions
13
13
14
-
Azure Static Web Apps provides serverless API endpoints via [Azure Functions](../azure-functions/functions-overview.md). By using Azure Functions, APIs dynamically scale based on demand, and include the following features:
14
+
Front end web applications often call back end APIs for data and services. By default, Azure Static Web Apps provides built-in serverless API endpoints via [Azure Functions](apis-functions.md).
15
15
16
-
-**Integrated security** with direct access to user [authentication and role-based authorization](user-information.md) data.
17
-
18
-
-**Seamless routing** that makes the _api_ route available to the web app securely without requiring custom CORS rules.
19
-
20
-
Azure Static Web Apps APIs are supported by two possible configurations depending on the [hosting plan](plans.md#features):
16
+
Azure Functions APIs in Static Web Apps are supported by two possible configurations depending on the [hosting plan](plans.md#features):
21
17
22
18
-**Managed functions**: By default, the API of a static web app is an Azure Functions application managed and deployed by Azure Static Web Apps associated with some restrictions.
23
19
@@ -26,12 +22,12 @@ Azure Static Web Apps APIs are supported by two possible configurations dependin
26
22
The following table contrasts the differences between using managed and existing functions.
27
23
28
24
| Feature | Managed Functions | Bring your own Functions |
29
-
|---|---|---|
30
-
| Access to Azure Functions [triggers](../azure-functions/functions-triggers-bindings.md#supported-bindings)|Http only | All |
25
+
|---|---|---|
26
+
| Access to Azure Functions [triggers](../azure-functions/functions-triggers-bindings.md#supported-bindings)|HTTP only | All |
|[Integrated security](user-information.md) with direct access to user authentication and role-based authorization data | ✔ | ✔ |
34
-
|[Routing integration](./configuration.md?#routes) that makes the _api_ route available to the web app securely without requiring custom CORS rules. | ✔ | ✔ |
30
+
|[Routing integration](./configuration.md?#routes) that makes the `/api` route available to the web app securely without requiring custom CORS rules. | ✔ | ✔ |
35
31
|[Durable Functions](../azure-functions/durable/durable-functions-overview.md) programming model | ✕ | ✔ |
|[Azure App Service Authentication and Authorization](../app-service/configure-authentication-provider-aad.md) token management | ✕ | ✔ |
@@ -40,29 +36,31 @@ The following table contrasts the differences between using managed and existing
40
36
41
37
<sup>1</sup> To specify the runtime version in managed functions, add a configuration file to your frontend app and set the [`apiRuntime` property](configuration.md#platform). Support is subject to the [Azure Functions language runtime support policy](../azure-functions/language-support-policy.md).
API endpoints are available to the web app through the _api_ route.
43
+
API endpoints are available to the web app through the `api` route.
46
44
47
45
| Managed functions | Bring your own functions |
48
-
|---|---|
49
-
| While the _api_ route is fixed, you have control over the source code folder location of the managed functions app. You can change this location by [editing the workflow YAML file](build-configuration.md) located in your repository's _.github/workflows_ folder. | Requests to the _api_ route are sent to your existing Azure Functions app. |
46
+
|---|---|
47
+
| While the `/api` route is fixed, you have control over the source code folder location of the managed functions app. You can change this location by [editing the workflow YAML file](build-configuration.md) located in your repository's _.github/workflows_ folder. | Requests to the `/api` route are sent to your existing Azure Functions app. |
50
48
51
49
## Troubleshooting and logs
52
50
53
51
Logs are only available if you add [Application Insights](monitor.md).
54
52
55
53
| Managed functions | Bring your own functions |
56
-
|---|---|
54
+
|---|---|
57
55
| Turn on logging by enabling Application Insights on your static web app. | Turn on logging by enabling Application Insights on your Azure Functions app. |
58
56
59
57
## Constraints
60
58
61
-
- The API route prefix must be _api_.
59
+
- The API route prefix must be `/api`.
62
60
- Route rules for API functions only support [redirects](configuration.md#defining-routes) and [securing routes with roles](configuration.md#securing-routes-with-roles).
63
61
64
62
| Managed functions | Bring your own functions |
65
-
|---|---|
63
+
|---|---|
66
64
| <ul><li>Triggers are limited to [HTTP](../azure-functions/functions-bindings-http-webhook.md).</li><li>The Azure Functions app must either be in Node.js 12, Node.js 14, Node.js 16, .NET Core 3.1, .NET 6.0, Python 3.8, or Python 3.9.</li><li>Some application settings are managed by the service, therefore the following prefixes are reserved by the runtime:<ul><li>*APPSETTING\_, AZUREBLOBSTORAGE\_, AZUREFILESSTORAGE\_, AZURE_FUNCTION\_, CONTAINER\_, DIAGNOSTICS\_, DOCKER\_, FUNCTIONS\_, IDENTITY\_, MACHINEKEY\_, MAINSITE\_, MSDEPLOY\_, SCMSITE\_, SCM\_, WEBSITES\_, WEBSITE\_, WEBSOCKET\_, AzureWeb*</li></ul></li><li>Some application tags are internally used by the service. Therefore, the following tags are reserved:<ul><li> *AccountId, EnvironmentId, FunctionAppId*.</li></ul></li></ul> | <ul><li>You are responsible to manage the Functions app deployment.</li></ul> |
0 commit comments