Skip to content

Commit 1f60464

Browse files
authored
Merge pull request #240142 from dlepow/odataapi
[APIM] Import OData API
2 parents 682ca9d + a98f72d commit 1f60464

18 files changed

+168
-18
lines changed

articles/api-management/TOC.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@
247247
href: import-logic-app-as-api.md
248248
- name: Configure Service Fabric backend
249249
href: how-to-configure-service-fabric-backend.md
250+
- name: Import OData API
251+
href: import-api-from-odata.md
250252
- name: Import SAP OData metadata
251253
href: sap-api.md
252254
- name: Configure API for SSE
@@ -558,6 +560,8 @@
558560
href: validate-headers-policy.md
559561
- name: validate-jwt
560562
href: validate-jwt-policy.md
563+
- name: validate-odata-request
564+
href: validate-odata-request-policy.md
561565
- name: validate-parameters
562566
href: validate-parameters-policy.md
563567
- name: validate-status-code

articles/api-management/api-management-policies.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ More information about policies:
9595

9696
- [Validate content](validate-content-policy.md) - Validates the size or content of a request or response body against one or more API schemas. The supported schema formats are JSON and XML.
9797
- [Validate GraphQL request](validate-graphql-request-policy.md) - Validates and authorizes a request to a GraphQL API.
98+
- [Validate OData request](validate-odata-request-policy.md) - Validates a request to an OData API to ensure conformance with the OData specification.
9899
- [Validate parameters](validate-parameters-policy.md) - Validates the request header, query, or path parameters against the API schema.
99100
- [Validate headers](validate-headers-policy.md) - Validates the response headers against the API schema.
100101
- [Validate status code](validate-status-code-policy.md) - Validates the HTTP status codes in responses against the API schema.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
title: Import an OData API to Azure API Management | Microsoft Docs
3+
description: Learn how to import an OData API to an API Management instance using the Azure portal.
4+
services: api-management
5+
author: dlepow
6+
7+
ms.service: api-management
8+
ms.topic: how-to
9+
ms.date: 06/06/2023
10+
ms.author: danlep
11+
ms.custom:
12+
---
13+
# Import an OData API
14+
15+
This article shows how to import an OData-compliant service as an API in API Management.
16+
17+
In this article, you learn how to:
18+
> [!div class="checklist"]
19+
> * Import an OData metadata description using the Azure portal
20+
> * Manage the OData schema in the portal
21+
> * Secure the OData API
22+
23+
> [!NOTE]
24+
> Importing an OData service as an API is in preview. Currently, testing OData APIs isn't supported in the test console of the Azure portal or in the API Management developer portal.
25+
26+
## Prerequisites
27+
28+
* An API Management instance. If you don't already have one, complete the following quickstart: [Create an Azure API Management instance](get-started-create-service-instance.md).
29+
30+
* A service exposed as OData v2 or v4.
31+
32+
[!INCLUDE [api-management-navigate-to-instance.md](../../includes/api-management-navigate-to-instance.md)]
33+
34+
## Import OData metadata
35+
36+
1. In the left menu, select **APIs** > **+ Add API**.
37+
1. Under **Create from definition**, select **OData**.
38+
39+
:::image type="content" source="media/import-api-from-odata/odata-api.png" alt-text="Screenshot of creating an API from an OData description in the portal." :::
40+
1. Enter API settings. You can update your settings later by going to the **Settings** tab of the API.
41+
42+
1. In **OData specification**, enter a URL for an OData metadata endpoint, typically the URL to the service root, appended with `/$metadata`. Alternatively, select a local OData XML file to import.
43+
44+
1. Enter remaining settings to configure your API. These settings are explained in the [Import and publish your first API](import-and-publish.md#import-and-publish-a-backend-api) tutorial.
45+
1. Select **Create**.
46+
47+
The API is added to the **APIs** list. The entity sets and functions that are exposed in the OData metadata description appear on the API's **Schema** tab.
48+
49+
:::image type="content" source="media/import-api-from-odata/odata-schema.png" alt-text="Screenshot of schema of OData API in the portal." :::
50+
51+
## Update the OData schema
52+
53+
You can access an editor in the portal to view your API's OData schema. If the API changes, you can also update the schema in API Management from a file or an OData service endpoint.
54+
55+
1. In the [portal](https://portal.azure.com), navigate to your API Management instance.
56+
1. In the left menu, select **APIs** > your OData API.
57+
1. On the **Schema** tab, select the edit (**\</>**) icon.
58+
1. Review the schema. If you want to update it, select **Update from file** or **Update schema from endpoint**.
59+
60+
:::image type="content" source="media/import-api-from-odata/odata-schema-update.png" alt-text="Screenshot of schema editor for OData API in the portal." :::
61+
62+
## Secure your OData API
63+
64+
Secure your OData API by applying both existing [access control policies](api-management-policies.md#access-restriction-policies) and an [OData validation policy](validate-odata-request-policy.md) to protect against attacks through OData API requests.
65+
66+
> [!TIP]
67+
> In the portal, configure policies for your OData API on the **API policies** tab.
68+
69+
[!INCLUDE [api-management-append-apis.md](../../includes/api-management-append-apis.md)]
70+
71+
[!INCLUDE [api-management-define-api-topics.md](../../includes/api-management-define-api-topics.md)]
72+
73+
## Next steps
74+
75+
> [!div class="nextstepaction"]
76+
> [Transform and protect a published API](transform-api.md)
9.04 KB
Loading
186 KB
Loading
81.5 KB
Loading

articles/api-management/sap-api.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ms.service: api-management
66
author: martinpankraz
77
ms.author: mapankra
88
ms.topic: how-to
9-
ms.date: 01/26/2022
9+
ms.date: 06/06/2023
1010
ms.custom:
1111
---
1212

@@ -21,6 +21,9 @@ In this article, you'll:
2121
> * Complete API configuration
2222
> * Test the API in the Azure portal
2323
24+
> [!NOTE]
25+
> In preview, API Management can now directly import an OData API from its metadata description, without requiring conversion to an OpenAPI specification. [Learn more](import-api-from-odata.md).
26+
2427
## Prerequisites
2528

2629
- An existing API Management instance. [Create one if you haven't already](get-started-create-service-instance.md).

articles/api-management/validate-graphql-request-policy.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ms.author: danlep
1212

1313
# Validate GraphQL request
1414

15-
The `validate-graphql-request` policy validates the GraphQL request and authorizes access to specific query paths. An invalid query is a "request error". Authorization is only done for valid requests.
15+
The `validate-graphql-request` policy validates the GraphQL request and authorizes access to specific query paths in a GraphQL API. An invalid query is a "request error". Authorization is only done for valid requests.
1616

1717
[!INCLUDE [api-management-policy-generic-alert](../../includes/api-management-policy-generic-alert.md)]
1818

@@ -68,24 +68,28 @@ Available actions are described in the following table.
6868
## Usage
6969

7070
- [**Policy sections:**](./api-management-howto-policies.md#sections) inbound
71-
- [**Policy scopes:**](./api-management-howto-policies.md#scopes) global, product, API, operation
71+
- [**Policy scopes:**](./api-management-howto-policies.md#scopes) global, workspace, product, API
7272
- [**Gateways:**](api-management-gateways-overview.md) dedicated, consumption, self-hosted
7373

7474
### Usage notes
7575

76-
Because GraphQL queries use a flattened schema, permissions may be applied at any leaf node of an output type:
77-
78-
* Mutation, query, or subscription
79-
* Individual field in a type declaration
80-
81-
Permissions may not be applied to:
82-
83-
* Input types
84-
* Fragments
85-
* Unions
86-
* Interfaces
87-
* The schema element
88-
76+
* Configure the policy for a [pass-through](graphql-api.md) or [synthetic](graphql-schema-resolve-api.md) GraphQL API that has been imported to API Management.
77+
78+
* This policy can only be used once in a policy section.
79+
80+
* Because GraphQL queries use a flattened schema, permissions may be applied at any leaf node of an output type:
81+
82+
* Mutation, query, or subscription
83+
* Individual field in a type declaration
84+
85+
Permissions may not be applied to:
86+
87+
* Input types
88+
* Fragments
89+
* Unions
90+
* Interfaces
91+
* The schema element
92+
8993
## Error handling
9094

9195
Failure to validate against the GraphQL schema, or a failure for the request's size or depth, is a request error and results in the request being failed with an errors block (but no data block).
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
title: Azure API Management policy reference - validate-odata-request | Microsoft Docs
3+
description: Reference for the validate-odata-request policy available for use in Azure API Management. Provides policy usage, settings, and examples.
4+
services: api-management
5+
author: dlepow
6+
7+
ms.service: api-management
8+
ms.topic: article
9+
ms.date: 06/06/2023
10+
ms.author: danlep
11+
---
12+
13+
# Validate OData request
14+
15+
The `validate-odata-request` policy validates the request URL, headers, and parameters of a request to an OData API to ensure conformance with the [OData specification](https://www.odata.org/documentation).
16+
17+
> [!NOTE]
18+
> This policy is currently in preview.
19+
20+
## Policy statement
21+
22+
```xml
23+
<validate-odata-request error-variable-name="variable name" default-odata-version="OData version number" min-odata-version="OData version number" max-odata-version="OData version number" max-size="size in bytes" />
24+
```
25+
26+
## Attributes
27+
28+
| Attribute | Description | Required | Default |
29+
| ----------------- | ------------------------------------------------------ | -------- | ------- |
30+
| error-variable-name | Name of the variable in `context.Variables` to log validation errors to. | No | N/A |
31+
| default-odata-version | The default OData version that is assumed for parameter validation if the request doesn't contain an `OData-Version` header. | No | 4.0 |
32+
| min-odata-version | The minimum OData version in the `OData-Version` header of the request that the policy accepts. | No | N/A |
33+
| max-odata-version | The maximum OData version in the `OData-Version` header of the request that the policy accepts. | No | N/A |
34+
| max-size | Maximum size of the request payload in bytes. | No | N/A |
35+
36+
37+
## Usage
38+
39+
- [**Policy sections:**](./api-management-howto-policies.md#sections) inbound
40+
- [**Policy scopes:**](./api-management-howto-policies.md#scopes) global, workspace, product, API
41+
- [**Gateways:**](api-management-gateways-overview.md) dedicated, consumption, self-hosted
42+
43+
### Usage notes
44+
45+
* Configure the policy for an OData API that has been [imported](import-api-from-odata.md) to API Management.
46+
* This policy can only be used once in a policy section.
47+
48+
## Example
49+
50+
The following example validates a request to an OData API and assumes a default OData version of 4.01 if no `OData-Version` header is present:
51+
52+
```xml
53+
<validate-odata-request default-odata-version="4.01" />
54+
```
55+
56+
## Related policies
57+
58+
* [Validation policies](api-management-policies.md#validation-policies)
59+
60+
[!INCLUDE [api-management-policy-ref-next-steps](../../includes/api-management-policy-ref-next-steps.md)]

includes/api-management-append-apis.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ ms.author: vlvinogr
88
## Append other APIs
99

1010
You can compose an API of APIs exposed by different services, including:
11-
* The OpenAPI Specification
11+
* An OpenAPI specification
1212
* A SOAP API
13+
* A GraphQL API
1314
* A Web App hosted in Azure App Service
1415
* Azure Function App
1516
* Azure Logic Apps

0 commit comments

Comments
 (0)