· 6 years ago · Mar 29, 2020, 12:28 PM
1{
2 "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
3 "contentVersion": "1.0.0.0",
4 "parameters": {
5 "apim-name": {
6 "defaultValue": "tostore-apim",
7 "type": "String"
8 },
9 "function-app-name": {
10 "defaultValue": "tostore-functionapp",
11 "type": "String"
12 },
13 "namedvalue-app-key-value": {
14 "type": "SecureString"
15 }
16 },
17 "variables": {
18 "function-app-sufix": "order",
19 "order-function-name": "tostore-function-order",
20 "namedvalue-app-key-display": "tostore-function-key"
21 },
22 "resources": [
23 {
24 "type": "Microsoft.ApiManagement/service",
25 "apiVersion": "2019-12-01-preview",
26 "name": "[parameters('apim-name')]",
27 "location": "West Europe",
28 "sku": {
29 "name": "Consumption",
30 "capacity": 0
31 },
32 "properties": {
33 "publisherEmail": "lautaro.arino@ibiz-solutions.se",
34 "publisherName": "lautaro",
35 "notificationSenderEmail": "apimgmt-noreply@mail.windowsazure.com",
36 "hostnameConfigurations": [
37 {
38 "type": "Proxy",
39 "hostName": "[concat(parameters('apim-name'), '.azure-api.net')]",
40 "negotiateClientCertificate": false,
41 "defaultSslBinding": true
42 }
43 ],
44 "customProperties": {
45 "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": "False",
46 "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": "False",
47 "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": "False",
48 "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": "False",
49 "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": "False",
50 "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2": "False"
51 },
52 "virtualNetworkType": "None",
53 "apiVersionConstraint": {}
54 }
55 },
56 {
57 "type": "Microsoft.ApiManagement/service/apis",
58 "apiVersion": "2019-12-01-preview",
59 "name": "[concat(parameters('apim-name'), '/',variables('function-app-sufix'))]",
60 "dependsOn": [
61 "[resourceId('Microsoft.ApiManagement/service', parameters('apim-name'))]"
62 ],
63 "properties": {
64 "displayName": "function-app-api",
65 "apiRevision": "1",
66 "description": "Function App",
67 "subscriptionRequired": true,
68 "path": "[variables('function-app-sufix')]",
69 "protocols": [
70 "https"
71 ],
72 "isCurrent": true
73 }
74 },
75 {
76 "type": "Microsoft.ApiManagement/service/backends",
77 "apiVersion": "2019-12-01-preview",
78 "name": "[concat(parameters('apim-name'), '/',variables('function-app-sufix'))]",
79 "dependsOn": [
80 "[resourceId('Microsoft.ApiManagement/service', parameters('apim-name'))]"
81 ],
82 "properties": {
83 "description": "backend for tostore function app ",
84 "url": "[listsecrets(resourceId('Microsoft.Web/sites/functions', parameters('function-app-name'),variables('order-function-name')),'2015-08-01').trigger_url]",
85 "protocol": "http",
86 "resourceId": "[resourceId('Microsoft.Web/sites/functions', parameters('function-app-name'), variables('order-function-name'))]",
87 "credentials": {
88 "header": {
89 "x-functions-key": [
90 "{{[variables('namedvalue-app-key-display')]}}"
91 ]
92 }
93 }
94 }
95 },
96 {
97 "type": "Microsoft.ApiManagement/service/namedValues",
98 "apiVersion": "2019-12-01-preview",
99 "name": "[concat(parameters('apim-name'),'/',variables('namedvalue-app-key-display'))]",
100 "dependsOn": [
101 "[resourceId('Microsoft.ApiManagement/service', parameters('apim-name'))]"
102 ],
103 "properties": {
104 "displayName": "[variables('namedvalue-app-key-display')]",
105 "tags": [
106 "key",
107 "function",
108 "auto"
109 ],
110 "secret": true,
111 "value": "[parameters('namedvalue-app-key-value')]"
112 }
113 },
114 {
115 "type": "Microsoft.ApiManagement/service/policies",
116 "apiVersion": "2019-12-01-preview",
117 "name": "[concat(parameters('apim-name'), '/policy')]",
118 "dependsOn": [
119 "[resourceId('Microsoft.ApiManagement/service', parameters('apim-name'))]"
120 ],
121 "properties": {
122 "value": "<!--\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 - Policies are applied in the order of their appearance, from the top down.\r\n-->\r\n<policies>\r\n <inbound></inbound>\r\n <backend>\r\n <forward-request />\r\n </backend>\r\n <outbound></outbound>\r\n</policies>",
123 "format": "xml"
124 }
125 },
126 {
127 "type": "Microsoft.ApiManagement/service/properties",
128 "apiVersion": "2019-01-01",
129 "name": "[concat(parameters('apim-name'),'/',variables('namedvalue-app-key-display'))]",
130 "dependsOn": [
131 "[resourceId('Microsoft.ApiManagement/service', parameters('apim-name'))]"
132 ],
133 "properties": {
134 "displayName": "[variables('namedvalue-app-key-display')]",
135 "value": "[listsecrets(resourceId('Microsoft.Web/sites/functions', parameters('apim-name'), variables('order-function-name')),'2015-08-01').key]",
136 "tags" : [
137 "key",
138 "function",
139 "auto"
140 ],
141 "secret": true
142 }
143 },
144 {
145 "type": "Microsoft.ApiManagement/service/apis/operations",
146 "apiVersion": "2019-12-01-preview",
147 "name": "[concat(parameters('apim-name'),'/',variables('function-app-sufix'),'/',variables('order-function-name'))]",
148 "dependsOn": [
149 "[resourceId('Microsoft.ApiManagement/service/apis', parameters('apim-name'), variables('function-app-sufix'))]",
150 "[resourceId('Microsoft.ApiManagement/service', parameters('apim-name'))]"
151 ],
152 "properties": {
153 "displayName": "variables('order-function-name')",
154 "method": "POST",
155 "urlTemplate": "/variables('order-function-name')",
156 "templateParameters": [],
157 "responses": []
158 }
159 },
160 {
161 "type": "Microsoft.ApiManagement/service/subscriptions",
162 "apiVersion": "2019-12-01-preview",
163 "name": "[concat(parameters('apim-name'), '/tostore-api-subscription')]",
164 "dependsOn": [
165 "[resourceId('Microsoft.ApiManagement/service', parameters('apim-name'))]",
166 "[resourceId('Microsoft.ApiManagement/service/apis', parameters('apim-name'), variables('function-app-sufix'))]"
167 ],
168 "properties": {
169 "scope": "[resourceId('Microsoft.ApiManagement/service/apis', parameters('apim-name'), variables('function-app-sufix'))]",
170 "displayName": "Testorder API Subscription",
171 "state": "active",
172 "allowTracing": false
173 }
174 },
175 {
176 "type": "Microsoft.ApiManagement/service/apis/operations/policies",
177 "apiVersion": "2019-12-01-preview",
178 "name": "[concat(parameters('apim-name'), '/',variables('function-app-sufix'),'/',variables('order-function-name') ,'/policy')]",
179 "dependsOn": [
180 "[resourceId('Microsoft.ApiManagement/service/apis/operations', parameters('apim-name'), variables('function-app-sufix'), variables('order-function-name'))]",
181 "[resourceId('Microsoft.ApiManagement/service/apis', parameters('apim-name'), variables('function-app-sufix'))]",
182 "[resourceId('Microsoft.ApiManagement/service', parameters('apim-name'))]"
183 ],
184 "properties": {
185 "value": "concat('<policies><inbound><base /><set-backend-service id=\"apim-generated-policy\"backend-id=\"','parameters('function-app-name')','\"/></inbound><backend><base/></backend><outbound><base/></outbound><on-error><base/></on-error></policies>')",
186 "format": "xml"
187 }
188 }
189 ]
190}