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
| Request Headers | Returns a list of the request headers sent to APIM. Useful for debugging. |
20
+
| API ID | Returns the ID of an API as per a predefined standard such as `api-123`. Useful for explicitly identifying an API in telemetry. |
21
+
15
22
## ⚙️ Configuration
16
23
17
24
1. Decide which of the [Infrastructure Architectures](../../README.md#infrastructure-architectures) you wish to use.
18
-
1. If the infrastructure _does not_ yet exist, navigate to the desired [infrastructure](../../infrastructure/) folder and follow its README.md.
19
-
1. If the infrastructure _does_ exist, adjust the `user-defined parameters` in the _Initialize notebook variables_ below. Please ensure that all parameters match your infrastructure.
25
+
1. Press `Run All` in this sample's `create.ipynb` notebook.
"request_headers_get = GET_APIOperation('Gets the request headers for the current request and returns them. Great for troubleshooting.', pol_request_headers_get)\n",
"# Preflight: Check if the infrastructure architecture deployment uses Azure Front Door. If so, assume that APIM is not directly accessible and use the Front Door URL instead.\n",
Tags are very useful to explicitly identify an API as API names or paths may be ambiguous and repetitive. Having explicit IDs can significantly aid with telemetry.
5
+
As there is no way yet to extract a tag associated with an API in Azure API Management using policies, putting such information in the API name is a workable alternative.
6
+
If the format is consistent, it can be parsed and used in the policies.
7
+
8
+
The format we are looking for is `<api-name> (api-246)`, where the value in parentheses starts with "api-" followed by numeric characters.
9
+
10
+
This fragment extracts the API ID from context.Api.Name and stores it in the "apiId" variable.
11
+
If the format doesn't match the expected pattern, the variable will be set to an empty string.
12
+
13
+
Expected format examples:
14
+
- "User Management API (api-246)" → extracts "api-246"
15
+
- "Order Service (api-123)" → extracts "api-123"
16
+
- "Payment Gateway (payment-456)" → ignored (doesn't start with "api-")
# The base policy fragments common to all infrastructures
61
61
self.base_pfs= [
62
+
PolicyFragment('Api-Id', utils.read_policy_xml(utils.determine_shared_policy_path('pf-api-id.xml')), 'Extracts a specific API identifier for tracing.'),
62
63
PolicyFragment('AuthZ-Match-All', utils.read_policy_xml(utils.determine_shared_policy_path('pf-authz-match-all.xml')), 'Authorizes if all of the specified roles match the JWT role claims.'),
63
64
PolicyFragment('AuthZ-Match-Any', utils.read_policy_xml(utils.determine_shared_policy_path('pf-authz-match-any.xml')), 'Authorizes if any of the specified roles match the JWT role claims.'),
64
65
PolicyFragment('Http-Response-200', utils.read_policy_xml(utils.determine_shared_policy_path('pf-http-response-200.xml')), 'Returns a 200 OK response for the current HTTP method.'),
0 commit comments