Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 1423fc7

Browse files
authored
Merge branch 'lucashh-logger-extraction' into odaibert/products
2 parents 5b307b2 + 6e1cdfc commit 1423fc7

39 files changed

+639
-352
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The proposed approach is illustrated in the below picture.
2828

2929
In this example, there are two deployment environments: Development and Production, each has its own API Management instance. API developers have access to the Development instance and can use it for developing and testing their APIs. The Production instance is managed by a designated team called the API publishers.
3030

31-
The key in this proposed approach is to keep all API Management configurations in Azure [Resource Manager templates](https://docs.microsoft.com/azure/azure-resource-manager/resource-group-authoring-templates). These templates should be kept in a source control system. We will use GIT throughout this example. As illustrated in the picture, there is a Publisher repository that contains all configurations of the Production API Management instance in a collection of tempaltes.
31+
The key in this proposed approach is to keep all API Management configurations in Azure [Resource Manager templates](https://docs.microsoft.com/azure/azure-resource-manager/resource-group-authoring-templates). These templates should be kept in a source control system. We will use GIT throughout this example. As illustrated in the picture, there is a Publisher repository that contains all configurations of the Production API Management instance in a collection of templates.
3232

3333
* **Service template**: contains all the service-level configurations of the API Management instance (e.g., pricing tier and custom domains).
3434
* **Shared templates**: contain shared resources throughout an API Management instance (e.g., groups, products, loggers).
@@ -40,6 +40,7 @@ API developers will fork the publisher repository to a developer repository and
4040
We realize there are two challenges for API developers when working with Resource Manager templates:
4141

4242
* First, API developers often work with [OpenAPI Specification](https://github.com/OAI/OpenAPI-Specification) and may not be familiar with Resource Manager schemas. Authoring templates manually might be an error-prone task. Therefore, we created a utility tool called [**Creator**](./src/APIM_ARMTemplate/README.md#Creator) to automate the creation of API templates based on an Open API Specification file. Optionally, developers can supply API Management policies for an API in XML format. Basically, the tool inserts the Open API specification and policies into a Resource Manager template in the proper format. With this tool, API developers can continue focusing on the formats and artifacts they are familiar with.
43+
4344
* Second, for customers who have already been using API Management, another challenge is how to extract existing configurations into Resource Manager templates. For those customers, We have created another tool called [**Extrator**](./src/APIM_ARMTemplate/README.md#extractor) to help them generate templates by extracting configurations from their exisitng API Management instances.
4445

4546
Once API developers have finished developing and testing an API, and have generated the API template, they can submit a pull request to merge the changes to the publisher repository. API publishers can validate the pull request and make sure the changes are safe and compliant. For example, they can check if only HTTPS is allowed to communicate with the API. Most of these validations can be automated as a step in the CI/CD pipeline. Once the changes are approved and merged successfully, API publishers can choose to deploy them to the Production instance either on schedule or on demand. The deployment of the templates can be automated using [Azure Pipeline](https://docs.microsoft.com/en-us/azure/devops/pipelines/?view=azure-devops), [PowerShell](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-template-deploy), [Azure CLI](Azure-cli-example.md) or other tools.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"ApimServiceName": {
6+
"value": "contoso-dev"
7+
},
8+
"UsernamePasswordSignup": {
9+
"value": false
10+
}
11+
}
12+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"ApimServiceName": {
6+
"type": "string"
7+
},
8+
"UsernamePasswordSignup": {
9+
"type": "bool",
10+
"defaultValue": false,
11+
"allowedValues": [
12+
true,
13+
false
14+
]
15+
}
16+
},
17+
"resources": [
18+
{
19+
"type": "Microsoft.ApiManagement/service/portalsettings",
20+
"name": "[concat(parameters('ApimServiceName'), '/signup')]",
21+
"apiVersion": "2018-01-01",
22+
"properties": {
23+
"enabled": "[parameters('UsernamePasswordSignup')]"
24+
}
25+
}
26+
]
27+
}

example/api-httpbin/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# ARM Template samples showing how to Create an API Version and Revision
2+
3+
The example shows how to create `Versions` and `Revisions` of a sample `HttpBin` API in ApiManagement service.
4+
5+
## Version Set
6+
- api-httpbin.version-set.template.json
7+
8+
Execute this template to create a new Version set `versionset-httpbin-api` in API Management service.
9+
10+
## v1
11+
- api-httpbin.v1.template.json
12+
13+
Execute this template to create a new `Http Bin` Api having a `GET` and `POST` Operation and associated to the `Started` Product.
14+
15+
## v2
16+
- api-httpbin.v2.template.json
17+
18+
Execute this template to create a new Version `v2` of the `Http Bin` API.
19+
20+
## v2-rev2
21+
- api-httpbin.v2-rev2.template
22+
23+
Execute this template to create a new revision of the `v2` `Http Bin` Api having which adds a `DELETE` Operation to the API.
24+
25+
## v2-switch-rev
26+
- api-httpbin.v2.switch.template.json
27+
28+
Execute this template to create a `beta` release and switch the `HttpBinAPI-v2;rev2` to be the current Api Revision of the `v2` `HttpBin` API.
Lines changed: 99 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,101 @@
11
{
2-
"$schema":
3-
"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
4-
"contentVersion": "1.0.0.0",
5-
"parameters": {
6-
"ApimServiceName": {
7-
"type": "string"
8-
},
9-
"repoBaseUrl":{
10-
"type": "string",
11-
"metadata": {
12-
"description": "Base URL of the repository"
13-
}
14-
}
2+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"ApimServiceName": {
6+
"type": "string"
7+
}
8+
},
9+
"variables": {},
10+
"resources": [
11+
{
12+
"type": "Microsoft.ApiManagement/service/apis",
13+
"name": "[concat(parameters('ApimServiceName'), '/httpBinAPI')]",
14+
"apiVersion": "2018-01-01",
15+
"scale": null,
16+
"properties": {
17+
"displayName": "HTTP Bin API",
18+
"apiRevision": "1",
19+
"description": "API Management facade for a very handy and free online HTTP tool",
20+
"serviceUrl": "https://httpbin.org",
21+
"path": "httpbin",
22+
"protocols": [
23+
"https"
24+
],
25+
"authenticationSettings": null,
26+
"subscriptionKeyParameterNames": null,
27+
"apiVersion": "v1",
28+
"apiVersionSetId": "[concat(resourceId('Microsoft.ApiManagement/service', parameters('ApimServiceName')), '/api-version-sets/versionset-httpbin-api')]"
29+
}
1530
},
16-
"variables": {},
17-
"resources": [
18-
{
19-
"type": "Microsoft.ApiManagement/service/apis",
20-
"name": "[concat(parameters('ApimServiceName'), '/httpBinAPI')]",
21-
"apiVersion": "2018-01-01",
22-
"scale": null,
23-
"properties": {
24-
"displayName": "HTTP Bin API",
25-
"apiRevision": "1",
26-
"description": "API Management facade for a very handy and free online HTTP tool",
27-
"serviceUrl": "https://httpbin.org",
28-
"path": "httpbin",
29-
"protocols": [
30-
"https"
31-
],
32-
"authenticationSettings": null,
33-
"subscriptionKeyParameterNames": null,
34-
"apiVersion": "v1",
35-
"apiVersionSetId": "[concat(resourceId('Microsoft.ApiManagement/service', parameters('ApimServiceName')), '/api-version-sets/versionset-httpbin-api')]"
36-
}
37-
},
38-
{
39-
"type": "Microsoft.ApiManagement/service/apis/operations",
40-
"name": "[concat(parameters('ApimServiceName'), '/httpBinAPI/get')]",
41-
"apiVersion": "2018-01-01",
42-
"scale": null,
43-
"properties": {
44-
"displayName": "Returns GET data.",
45-
"method": "GET",
46-
"urlTemplate": "/get",
47-
"templateParameters": [],
48-
"description": "Returns GET data.\n",
49-
"responses": [
50-
{
51-
"statusCode": 200,
52-
"description": "OK",
53-
"headers": []
54-
}
55-
],
56-
"policies": null
57-
},
58-
"dependsOn": [
59-
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('ApimServiceName'), 'httpBinAPI')]"
60-
]
61-
},
62-
63-
{
64-
"type": "Microsoft.ApiManagement/service/apis/operations",
65-
"name": "[concat(parameters('ApimServiceName'), '/httpBinAPI/post')]",
66-
"apiVersion": "2018-01-01",
67-
"scale": null,
68-
"properties": {
69-
"displayName": "Returns POST data.",
70-
"method": "POST",
71-
"urlTemplate": "/post",
72-
"templateParameters": [],
73-
"description": "Returns POST data.\n",
74-
"responses": [
75-
{
76-
"statusCode": 200,
77-
"description": "OK",
78-
"headers": []
79-
}
80-
],
81-
"policies": null
82-
},
83-
"dependsOn": [
84-
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('ApimServiceName'), 'httpBinAPI')]"
85-
]
86-
},
87-
{
88-
"type": "Microsoft.ApiManagement/service/products/apis",
89-
"name": "[concat(parameters('ApimServiceName'), '/starter/httpBinAPI')]",
90-
"apiVersion": "2018-01-01",
91-
"scale": null,
92-
"properties": {},
93-
"dependsOn": [
94-
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('ApimServiceName'), 'httpBinAPI')]"
95-
]
96-
},
97-
{
98-
"type": "Microsoft.ApiManagement/service/apis/policies",
99-
"name":
100-
"[concat(parameters('ApimServiceName'), '/httpBinAPI/policy')]",
101-
"apiVersion": "2018-01-01",
102-
"properties": {
103-
"policyContent": "[concat('<!--\r\n IMPORTANT:\r\n - Policy elements can appear only within the <inbound>, <outbound>, <backend> section elements.\r\n - Only the <forward-request> policy element can appear within the <backend> section element.\r\n - To apply a policy to the incoming request (before it is forwarded to the backend service), place a corresponding policy element within the <inbound> section element.\r\n - To apply a policy to the outgoing response (before it is sent back to the caller), place a corresponding policy element within the <outbound> section element.\r\n - To add a policy position the cursor at the desired insertion point and click on the round button associated with the policy.\r\n - To remove a policy, delete the corresponding policy statement from the policy document.\r\n - Position the <base> element within a section element to inherit all policies from the corresponding section element in the enclosing scope.\r\n - Remove the <base> element to prevent inheriting policies from the corresponding section element in the enclosing scope.\r\n - Policies are applied in the order of their appearance, from the top down.\r\n-->\r\n<policies>\r\n <inbound>\r\n <base />\r\n <set-backend-service base-url=\"https://api.apis.guru/v2/\" />\r\n <rewrite-uri template=\"/metrics.json\" />\r\n </inbound>\r\n <backend>\r\n <base />\r\n </backend>\r\n <outbound>\r\n <base />\r\n </outbound>\r\n <on-error>\r\n <base />\r\n </on-error>\r\n</policies>')]"
104-
},
105-
"dependsOn": [
106-
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('ApimServiceName'), 'httpBinAPI')]"
107-
]
108-
}
109-
]
110-
}
31+
{
32+
"type": "Microsoft.ApiManagement/service/apis/operations",
33+
"name": "[concat(parameters('ApimServiceName'), '/httpBinAPI/get')]",
34+
"apiVersion": "2018-01-01",
35+
"scale": null,
36+
"properties": {
37+
"displayName": "Returns GET data.",
38+
"method": "GET",
39+
"urlTemplate": "/get",
40+
"templateParameters": [],
41+
"description": "Returns GET data.\n",
42+
"responses": [
43+
{
44+
"statusCode": 200,
45+
"description": "OK",
46+
"headers": []
47+
}
48+
],
49+
"policies": null
50+
},
51+
"dependsOn": [
52+
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('ApimServiceName'), 'httpBinAPI')]"
53+
]
54+
},
55+
{
56+
"type": "Microsoft.ApiManagement/service/apis/operations",
57+
"name": "[concat(parameters('ApimServiceName'), '/httpBinAPI/post')]",
58+
"apiVersion": "2018-01-01",
59+
"scale": null,
60+
"properties": {
61+
"displayName": "Returns POST data.",
62+
"method": "POST",
63+
"urlTemplate": "/post",
64+
"templateParameters": [],
65+
"description": "Returns POST data.\n",
66+
"responses": [
67+
{
68+
"statusCode": 200,
69+
"description": "OK",
70+
"headers": []
71+
}
72+
],
73+
"policies": null
74+
},
75+
"dependsOn": [
76+
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('ApimServiceName'), 'httpBinAPI')]"
77+
]
78+
},
79+
{
80+
"type": "Microsoft.ApiManagement/service/products/apis",
81+
"name": "[concat(parameters('ApimServiceName'), '/starter/httpBinAPI')]",
82+
"apiVersion": "2018-01-01",
83+
"scale": null,
84+
"properties": {},
85+
"dependsOn": [
86+
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('ApimServiceName'), 'httpBinAPI')]"
87+
]
88+
},
89+
{
90+
"type": "Microsoft.ApiManagement/service/apis/policies",
91+
"name": "[concat(parameters('ApimServiceName'), '/httpBinAPI/policy')]",
92+
"apiVersion": "2018-01-01",
93+
"properties": {
94+
"policyContent": "[concat('<!--\r\n IMPORTANT:\r\n - Policy elements can appear only within the <inbound>, <outbound>, <backend> section elements.\r\n - Only the <forward-request> policy element can appear within the <backend> section element.\r\n - To apply a policy to the incoming request (before it is forwarded to the backend service), place a corresponding policy element within the <inbound> section element.\r\n - To apply a policy to the outgoing response (before it is sent back to the caller), place a corresponding policy element within the <outbound> section element.\r\n - To add a policy position the cursor at the desired insertion point and click on the round button associated with the policy.\r\n - To remove a policy, delete the corresponding policy statement from the policy document.\r\n - Position the <base> element within a section element to inherit all policies from the corresponding section element in the enclosing scope.\r\n - Remove the <base> element to prevent inheriting policies from the corresponding section element in the enclosing scope.\r\n - Policies are applied in the order of their appearance, from the top down.\r\n-->\r\n<policies>\r\n <inbound>\r\n <base />\r\n <set-backend-service base-url=\"https://api.apis.guru/v2/\" />\r\n <rewrite-uri template=\"/metrics.json\" />\r\n </inbound>\r\n <backend>\r\n <base />\r\n </backend>\r\n <outbound>\r\n <base />\r\n </outbound>\r\n <on-error>\r\n <base />\r\n </on-error>\r\n</policies>')]"
95+
},
96+
"dependsOn": [
97+
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('ApimServiceName'), 'httpBinAPI')]"
98+
]
99+
}
100+
]
101+
}

0 commit comments

Comments
 (0)