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

Commit 6518dd7

Browse files
committed
refactored
1 parent 0d5337d commit 6518dd7

File tree

7 files changed

+260
-326
lines changed

7 files changed

+260
-326
lines changed

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+
}

example/api-switch-revision/rev2/api-httpbin.rev2.template.json renamed to example/api-httpbin/v2-rev2/api-httpbin.v2-rev2.template.json

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,24 @@
1010
"resources": [
1111
{
1212
"type": "Microsoft.ApiManagement/service/apis",
13-
"name": "[concat(parameters('ApimServiceName'), '/httpBinAPI;rev=2')]",
13+
"name": "[concat(parameters('ApimServiceName'), '/httpBinAPI-v2;rev=2')]",
1414
"apiVersion": "2018-01-01",
1515
"properties": {
1616
"displayName": "HTTP Bin API",
17+
"apiRevision": "1",
1718
"description": "API Management facade for a very handy and free online HTTP tool",
1819
"serviceUrl": "https://httpbin.org",
1920
"path": "httpbin",
2021
"protocols": [
2122
"https"
22-
]
23+
],
24+
"apiVersion": "v2",
25+
"apiVersionSetId": "[concat(resourceId('Microsoft.ApiManagement/service', parameters('ApimServiceName')), '/api-version-sets/versionset-httpbin-api')]"
2326
}
2427
},
2528
{
2629
"type": "Microsoft.ApiManagement/service/apis/operations",
27-
"name": "[concat(parameters('ApimServiceName'), '/httpBinAPI;rev=2/get')]",
30+
"name": "[concat(parameters('ApimServiceName'), '/httpBinAPI-v2;rev=2/get')]",
2831
"apiVersion": "2018-01-01",
2932
"scale": null,
3033
"properties": {
@@ -42,12 +45,12 @@
4245
]
4346
},
4447
"dependsOn": [
45-
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('ApimServiceName'), 'httpBinAPI;rev=2')]"
48+
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('ApimServiceName'), 'httpBinAPI-v2;rev=2')]"
4649
]
4750
},
4851
{
4952
"type": "Microsoft.ApiManagement/service/apis/operations",
50-
"name": "[concat(parameters('ApimServiceName'), '/httpBinAPI;rev=2/post')]",
53+
"name": "[concat(parameters('ApimServiceName'), '/httpBinAPI-v2;rev=2/post')]",
5154
"apiVersion": "2018-01-01",
5255
"scale": null,
5356
"properties": {
@@ -65,28 +68,51 @@
6568
]
6669
},
6770
"dependsOn": [
68-
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('ApimServiceName'), 'httpBinAPI;rev=2')]"
71+
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('ApimServiceName'), 'httpBinAPI-v2;rev=2')]"
72+
]
73+
},
74+
{
75+
"type": "Microsoft.ApiManagement/service/apis/operations",
76+
"name": "[concat(parameters('ApimServiceName'), '/httpBinAPI-v2;rev=2/remove-resource')]",
77+
"apiVersion": "2018-01-01",
78+
"scale": null,
79+
"properties": {
80+
"displayName": "Remove resource",
81+
"method": "DELETE",
82+
"urlTemplate": "/resource",
83+
"templateParameters": [],
84+
"description": "A demonstration of a DELETE call which traditionally deletes the resource.",
85+
"responses": [
86+
{
87+
"statusCode": 200,
88+
"representations": [],
89+
"headers": []
90+
}
91+
]
92+
},
93+
"dependsOn": [
94+
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('ApimServiceName'), 'httpBinAPI-v2;rev=2')]"
6995
]
7096
},
7197
{
7298
"type": "Microsoft.ApiManagement/service/products/apis",
73-
"name": "[concat(parameters('ApimServiceName'), '/starter/httpBinAPI;rev=2')]",
99+
"name": "[concat(parameters('ApimServiceName'), '/starter/httpBinAPI-v2;rev=2')]",
74100
"apiVersion": "2018-01-01",
75101
"scale": null,
76102
"properties": {},
77103
"dependsOn": [
78-
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('ApimServiceName'), 'httpBinAPI;rev=2')]"
104+
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('ApimServiceName'), 'httpBinAPI-v2;rev=2')]"
79105
]
80106
},
81107
{
82108
"type": "Microsoft.ApiManagement/service/apis/policies",
83-
"name": "[concat(parameters('ApimServiceName'), '/httpBinAPI;rev=2/policy')]",
109+
"name": "[concat(parameters('ApimServiceName'), '/httpBinAPI-v2;rev=2/policy')]",
84110
"apiVersion": "2018-01-01",
85111
"properties": {
86112
"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>')]"
87113
},
88114
"dependsOn": [
89-
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('ApimServiceName'), 'httpBinAPI;rev=2')]"
115+
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('ApimServiceName'), 'httpBinAPI-v2;rev=2')]"
90116
]
91117
}
92118
]

example/api-switch-revision/switch/api-httpbin.switch.template.json renamed to example/api-httpbin/v2-switch-rev/api-httpbin.v2.switch.template.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
"resources": [
1010
{
1111
"type": "Microsoft.ApiManagement/service/apis/releases",
12-
"name": "[concat(parameters('ApimServiceName'), '/httpBinAPI', '/beta')]",
12+
"name": "[concat(parameters('ApimServiceName'), '/httpBinAPI-v2', '/beta')]",
1313
"apiVersion": "2018-01-01",
1414
"properties": {
15-
"apiId": "[resourceId('Microsoft.ApiManagement/service/apis', parameters('ApimServiceName'), 'httpBinAPI;rev=2')]",
15+
"apiId": "[resourceId('Microsoft.ApiManagement/service/apis', parameters('ApimServiceName'), 'httpBinAPI-v2;rev=2')]",
1616
"notes": "make revision 2 as current"
1717
}
1818
}

0 commit comments

Comments
 (0)