/
routingmanager.apim.json
609 lines (609 loc) · 55.4 KB
/
routingmanager.apim.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"apimServiceName": {
"type": "string",
"minLength": 1,
"maxLength": 50,
"metadata": {
"description": "Name of the APIM service this API is to be deployed to."
}
},
"apiName": {
"type": "string",
"minLength": 1,
"maxLength": 256,
"defaultValue": "aimroutingmanager",
"metadata": {
"description": "Name of this API."
}
},
"routingManagerAppServiceName": {
"type": "string",
"minLength": 2,
"maxLength": 60,
"metadata": {
"description": "Name of the App Service for the RoutingManager function."
}
},
"cacheTimeout": {
"type": "string",
"defaultValue": "21600",
"metadata": {
"description": "Amount of time (in seconds) that config entries are cached for, before they are retrieved again."
}
}
},
"variables": {
"aimCacheTimeoutNamedValue": "aimcachetimeout",
"aimSubscriptionIdNamedValue": "aimsubscriptionid",
"apiTagName": "[concat(parameters('apiName'), 'tag')]"
},
"resources": [
{
"type": "Microsoft.ApiManagement/service/apis",
"apiVersion": "2019-12-01",
"name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'))]",
"dependsOn": [
],
"properties": {
"displayName": "Routing Manager",
"description": "AIM Routing Manager API - handles routing of messages and retrieval of routing-related properties.",
"apiRevision": "1",
"subscriptionRequired": true,
"path": "aimroutingmanager",
"protocols": [
"https"
],
"isCurrent": true
},
"resources": [
]
},
{
"type": "Microsoft.ApiManagement/service/apis/tags",
"apiVersion": "2019-12-01",
"name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'), '/', variables('apiTagName'))]",
"dependsOn": [
"[resourceId('Microsoft.ApiManagement/service/tags', parameters('apimServiceName'), variables('apiTagName'))]",
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), parameters('apiName'))]"
],
"properties": {
}
},
{
"type": "Microsoft.ApiManagement/service/backends",
"apiVersion": "2019-12-01",
"name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'))]",
"dependsOn": [],
"properties": {
"description": "AIM Routing Manager Function Backend",
"url": "[concat('https://', parameters('routingManagerAppServiceName'), '.azurewebsites.net/api')]",
"protocol": "http",
"resourceId": "[concat('https://management.azure.com', resourceId('Microsoft.Web/sites', parameters('routingManagerAppServiceName')))]",
"credentials": {
"header": {
"x-functions-key": [
"[listkeys(concat(resourceId('Microsoft.Web/sites/', parameters('routingManagerAppServiceName')), '/host/default/'),'2016-08-01').functionKeys.apiManagement]"
]
}
}
}
},
{
"type": "Microsoft.ApiManagement/service/apis/operations",
"apiVersion": "2019-12-01",
"name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'), '/sendtonextroute')]",
"dependsOn": [
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), parameters('apiName'))]"
],
"properties": {
"displayName": "SendToNextRoute",
"description": "Sends the envelope to the next destination in the routing slip and if there are no more destinations, returns an ACK message.",
"method": "POST",
"urlTemplate": "/sendtonextroute",
"templateParameters": [],
"request": {
"description": "JSON payload containing an envelope message.",
"queryParameters": [
{
"name": "clearCache",
"description": "If true, then any cached config is cleared, and config is retrieved from App Config again.",
"type": "bool",
"defaultValue": "false",
"values": [
"true",
"false"
]
},
{
"name": "enableTrace",
"description": "If true, then an APIM trace URL is returned as a response header.",
"type": "bool",
"defaultValue": "false",
"values": [
"true",
"false"
]
}
],
"headers": [
{
"name": "Aim-Tracking-Id",
"description": "Tracking ID used to link disparate messages together by AIM.",
"type": "string",
"required": false,
"defaultValue": ""
}
],
"representations": [
{
"contentType": "text/json",
"sample": "{\r\n \"header\": {\r\n \"properties\": {},\r\n \"state\": {},\r\n \"routing\": {},\r\n \"routingSlip\": {\r\n \"scenario\": \"\",\r\n \"nextRoute\": 0,\r\n \"routes\": []\r\n }\r\n },\r\n \"body\": []\r\n}"
},
{
"contentType": "application/json",
"sample": "{\r\n \"header\": {\r\n \"properties\": {},\r\n \"state\": {},\r\n \"routing\": {},\r\n \"routingSlip\": {\r\n \"scenario\": \"\",\r\n \"nextRoute\": 0,\r\n \"routes\": []\r\n }\r\n },\r\n \"body\": []\r\n}"
}
]
},
"responses": [
{
"statusCode": 200,
"description": "Have sent the envelope to the next route, and an ACK or NACK message has been returned.",
"representations": [
{
"contentType": "application/json",
"sample": "{\r\n \"header\": {\r\n \"properties\": {\r\n \"createDate\": \"2020-06-18T12:07:48.8125659Z\",\r\n \"envelopeType\": \"ack\",\r\n \"messageId\": \"f655c39f-55af-4255-afc2-813d765b6156\",\r\n \"rootPart\": 1\r\n },\r\n \"routing\": {\r\n \"MessageType\": \"http://schemas.microsoft.com/aim#ack\"\r\n },\r\n \"routingSlip\": {},\r\n \"state\": {}\r\n }\r\n \"body\": [\r\n {\r\n \"$contentType\": \"application/json\",\r\n \"$part\": 1,\r\n \"$partType\": \"http://schemas.microsoft.com/aim#ack\",\r\n\t\t\t\"$content\": \"No more routes to process in RoutingSlip\"\r\n }\r\n ]\r\n}"
}
],
"headers": []
},
{
"statusCode": 500,
"description": "An internal error has occurred, and a fault object has been returned.",
"representations": [
{
"contentType": "application/json",
"sample": "{\r\n \"fault\": {\r\n \"faultActor\": \"SendToNextRoute\",\r\n \"faultCode\": \"500\",\r\n \"faultReason\": \"Unknown error\",\r\n \"faultCategory\": \"Error\",\r\n \"faultMessage\": \"The supplied request body contains an empty JSON array\"\r\n }\r\n}"
}
],
"headers": []
}
]
}
},
{
"type": "Microsoft.ApiManagement/service/apis/operations",
"apiVersion": "2019-12-01",
"name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'), '/resolveroutingproperties')]",
"dependsOn": [
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), parameters('apiName'))]"
],
"properties": {
"displayName": "ResolveRoutingProperties",
"description": "Calculates the routing properties for this envelope, adds them to the routing section and returns the updated envelope.",
"method": "POST",
"urlTemplate": "/resolveroutingproperties",
"templateParameters": [],
"request": {
"description": "JSON payload containing an envelope message.",
"queryParameters": [
{
"name": "clearCache",
"description": "If true, then any cached config is cleared, and config is retrieved from App Config again.",
"type": "bool",
"defaultValue": "false",
"values": [
"true",
"false"
]
},
{
"name": "enableTrace",
"description": "If true, then an APIM trace URL is returned as a response header.",
"type": "bool",
"defaultValue": "false",
"values": [
"true",
"false"
]
}
],
"headers": [
{
"name": "Aim-Tracking-Id",
"description": "Tracking ID used to link disparate messages together by AIM.",
"type": "string",
"required": false,
"defaultValue": ""
}
],
"representations": [
{
"contentType": "text/json",
"sample": "{\r\n \"header\": {\r\n \"properties\": {},\r\n \"state\": {},\r\n \"routing\": {},\r\n \"routingSlip\": {\r\n \"scenario\": \"\",\r\n \"nextRoute\": 0,\r\n \"routes\": []\r\n }\r\n },\r\n \"body\": []\r\n}"
},
{
"contentType": "application/json",
"sample": "{\r\n \"header\": {\r\n \"properties\": {},\r\n \"state\": {},\r\n \"routing\": {},\r\n \"routingSlip\": {\r\n \"scenario\": \"\",\r\n \"nextRoute\": 0,\r\n \"routes\": []\r\n }\r\n },\r\n \"body\": []\r\n}"
}
]
},
"responses": [
{
"statusCode": 200,
"description": "Routing properties have been calculated and an updated envelope message has been returned.",
"representations": [
{
"contentType": "application/json",
"sample": "{\r\n \"header\": {\r\n \"properties\": {},\r\n \"state\": {},\r\n \"routing\": {},\r\n \"routingSlip\": {\r\n \"scenario\": \"\",\r\n \"nextRoute\": 0,\r\n \"routes\": []\r\n }\r\n },\r\n \"body\": []\r\n}"
}
],
"headers": []
},
{
"statusCode": 500,
"description": "An internal error has occurred, and a fault object has been returned.",
"representations": [
{
"contentType": "application/json",
"sample": "{\r\n \"fault\": {\r\n \"faultActor\": \"ResolveRoutingProperties\",\r\n \"faultCode\": \"500\",\r\n \"faultReason\": \"Unknown error\",\r\n \"faultCategory\": \"Error\",\r\n \"faultMessage\": \"The supplied request body contains an empty JSON array\"\r\n }\r\n}"
}
],
"headers": []
}
]
}
},
{
"type": "Microsoft.ApiManagement/service/apis/operations",
"apiVersion": "2019-12-01",
"name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'), '/demotemessageproperties')]",
"dependsOn": [
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), parameters('apiName'))]"
],
"properties": {
"displayName": "DemoteMessageProperties",
"description": "Demotes message properties into the body content and returns the updated envelope.",
"method": "POST",
"urlTemplate": "/demotemessageproperties",
"templateParameters": [],
"request": {
"description": "JSON payload containing an envelope message.",
"queryParameters": [
{
"name": "clearCache",
"description": "If true, then any cached config is cleared, and config is retrieved from App Config again.",
"type": "bool",
"defaultValue": "false",
"values": [
"true",
"false"
]
},
{
"name": "enableTrace",
"description": "If true, then an APIM trace URL is returned as a response header.",
"type": "bool",
"defaultValue": "false",
"values": [
"true",
"false"
]
}
],
"headers": [
{
"name": "Aim-Tracking-Id",
"description": "Tracking ID used to link disparate messages together by AIM.",
"type": "string",
"required": false,
"defaultValue": ""
}
],
"representations": [
{
"contentType": "text/json",
"sample": "{\r\n \"header\": {\r\n \"properties\": {},\r\n \"state\": {},\r\n \"routing\": {},\r\n \"routingSlip\": {\r\n \"scenario\": \"\",\r\n \"nextRoute\": 0,\r\n \"routes\": []\r\n }\r\n },\r\n \"body\": []\r\n}"
},
{
"contentType": "application/json",
"sample": "{\r\n \"header\": {\r\n \"properties\": {},\r\n \"state\": {},\r\n \"routing\": {},\r\n \"routingSlip\": {\r\n \"scenario\": \"\",\r\n \"nextRoute\": 0,\r\n \"routes\": []\r\n }\r\n },\r\n \"body\": []\r\n}"
}
]
},
"responses": [
{
"statusCode": 200,
"description": "Message properties have been demoted and an updated envelope message has been returned.",
"representations": [
{
"contentType": "application/json",
"sample": "{\r\n \"header\": {\r\n \"properties\": {},\r\n \"state\": {},\r\n \"routing\": {},\r\n \"routingSlip\": {\r\n \"scenario\": \"\",\r\n \"nextRoute\": 0,\r\n \"routes\": []\r\n }\r\n },\r\n \"body\": []\r\n}"
}
],
"headers": []
},
{
"statusCode": 500,
"description": "An internal error has occurred, and a fault object has been returned.",
"representations": [
{
"contentType": "application/json",
"sample": "{\r\n \"fault\": {\r\n \"faultActor\": \"DemoteMessageProperties\",\r\n \"faultCode\": \"500\",\r\n \"faultReason\": \"Unknown error\",\r\n \"faultCategory\": \"Error\",\r\n \"faultMessage\": \"The supplied request body contains an empty JSON array\"\r\n }\r\n}"
}
],
"headers": []
}
]
}
},
{
"type": "Microsoft.ApiManagement/service/apis/operations",
"apiVersion": "2019-12-01",
"name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'), '/getlogicappcallbackurl')]",
"dependsOn": [
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), parameters('apiName'))]"
],
"properties": {
"displayName": "GetLogicAppCallbackUrl",
"description": "Gets the Callback URL for a given LogicApp.",
"method": "GET",
"urlTemplate": "/logicappcallbackurl/{resourceGroupName}/{logicAppName}",
"templateParameters": [
{
"name": "resourceGroupName",
"description": "Name of the Resource Group the LogicApp is in.",
"type": "string",
"required": true,
"values": []
},
{
"name": "logicAppName",
"description": "Name of the LogicApp to get the CallbackUrl for.",
"type": "string",
"required": true,
"values": []
}
],
"request": {
"queryParameters": [
{
"name": "clearCache",
"description": "If true, then the cache is cleared before retrieving config items.",
"type": "bool",
"defaultValue": "false",
"values": [
"true",
"false"
]
}
],
"headers": [],
"representations": []
},
"responses": [
{
"statusCode": 200,
"description": "Successfully retrieved a LogicApp Callback URL.",
"representations": [
{
"contentType": "application/json",
"sample": "{\r\n \"logicAppUrl\": \"https://prod-20.westus.logic.azure.com:443/workflows/\"\r\n}\r\n"
}
],
"headers": []
},
{
"statusCode": 500,
"description": "An internal error has occurred retrieving a LogicApp Callback URL, a Fault message will be returned",
"representations": [
{
"contentType": "application/json",
"sample": "{\r\n\t\"fault\": {\r\n\t\t\"faultActor\": \"\",\r\n\t\t\"faultCategory\": \"Error\",\r\n\t\t\"faultCode\": \"500\",\r\n\t\t\"faultMessage\": \"\",\r\n\t\t\"faultReason\": \"\"\r\n\t}\r\n}\r\n"
}
],
"headers": []
}
]
}
},
{
"type": "Microsoft.ApiManagement/service/apis/operations",
"apiVersion": "2021-01-01-preview",
"name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'), '/getstandardlogicappcallbackurl')]",
"dependsOn": [
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), parameters('apiName'))]"
],
"properties": {
"displayName": "GetStandardLogicAppCallbackUrl",
"description": "Gets the Callback URL for a given Standard Logic App Workflow.",
"method": "GET",
"urlTemplate": "/standardlogicappcallbackurl/{resourceGroupName}/{logicAppName}/{workflowName}",
"templateParameters": [
{
"name": "resourceGroupName",
"description": "Name of the Resource Group the Standard LogicApp is in.",
"type": "string",
"required": true,
"values": []
},
{
"name": "logicAppName",
"description": "Name of the Standard LogicApp to get the CallbackUrl for.",
"type": "string",
"required": true,
"values": []
},
{
"name": "workflowName",
"description": "Name of the Workflow to get the CallbackUrl for.",
"type": "string",
"required": true,
"values": []
}
],
"request": {
"queryParameters": [
{
"name": "clearCache",
"description": "If true, then the cache is cleared before retrieving the callback Url.",
"type": "bool",
"defaultValue": "false",
"values": [
"true",
"false"
]
}
],
"headers": [],
"representations": []
},
"responses": [
{
"statusCode": 200,
"description": "Successfully retrieved a Standard Logic App Callback URL.",
"representations": [
{
"contentType": "application/json",
"sample": "{\r\n \"logicAppUrl\": \"https://prod-20.westus.logic.azure.com:443/workflows/\"\r\n}\r\n"
}
],
"headers": []
},
{
"statusCode": 500,
"description": "An internal error has occurred retrieving a Standard Logic App Callback URL, a Fault message will be returned",
"representations": [
{
"contentType": "application/json",
"sample": "{\r\n\t\"fault\": {\r\n\t\t\"faultActor\": \"\",\r\n\t\t\"faultCategory\": \"Error\",\r\n\t\t\"faultCode\": \"500\",\r\n\t\t\"faultMessage\": \"\",\r\n\t\t\"faultReason\": \"\"\r\n\t}\r\n}\r\n"
}
],
"headers": []
}
]
}
},
{
"type": "Microsoft.ApiManagement/service/apis/operations/policies",
"apiVersion": "2019-12-01",
"name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'), '/sendtonextroute/policy')]",
"dependsOn": [
"[resourceId('Microsoft.ApiManagement/service/apis/operations', parameters('apimServiceName'), parameters('apiName'), 'sendtonextroute')]",
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), parameters('apiName'))]",
"[resourceId('Microsoft.ApiManagement/service/backends', parameters('apimServiceName'), parameters('apiName'))]",
"[resourceId('Microsoft.ApiManagement/service/namedValues', parameters('apimServiceName'), variables('aimCacheTimeoutNamedValue'))]",
"[resourceId('Microsoft.ApiManagement/service/namedValues', parameters('apimServiceName'), variables('aimSubscriptionIdNamedValue'))]"
],
"properties": {
"value": "<policies>\r\n <inbound>\r\n <base />\r\n <set-backend-service id=\"apim-generated-policy\" backend-id=\"aimroutingmanager\" />\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>",
"format": "xml"
}
},
{
"type": "Microsoft.ApiManagement/service/apis/operations/policies",
"apiVersion": "2019-12-01",
"name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'), '/resolveroutingproperties/policy')]",
"dependsOn": [
"[resourceId('Microsoft.ApiManagement/service/apis/operations', parameters('apimServiceName'), parameters('apiName'), 'resolveroutingproperties')]",
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), parameters('apiName'))]",
"[resourceId('Microsoft.ApiManagement/service/backends', parameters('apimServiceName'), parameters('apiName'))]",
"[resourceId('Microsoft.ApiManagement/service/namedValues', parameters('apimServiceName'), variables('aimCacheTimeoutNamedValue'))]",
"[resourceId('Microsoft.ApiManagement/service/namedValues', parameters('apimServiceName'), variables('aimSubscriptionIdNamedValue'))]"
],
"properties": {
"value": "<policies>\r\n <inbound>\r\n <base />\r\n <set-backend-service id=\"apim-generated-policy\" backend-id=\"aimroutingmanager\" />\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>",
"format": "xml"
}
},
{
"type": "Microsoft.ApiManagement/service/apis/operations/policies",
"apiVersion": "2019-12-01",
"name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'), '/demotemessageproperties/policy')]",
"dependsOn": [
"[resourceId('Microsoft.ApiManagement/service/apis/operations', parameters('apimServiceName'), parameters('apiName'), 'demotemessageproperties')]",
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), parameters('apiName'))]",
"[resourceId('Microsoft.ApiManagement/service/backends', parameters('apimServiceName'), parameters('apiName'))]",
"[resourceId('Microsoft.ApiManagement/service/namedValues', parameters('apimServiceName'), variables('aimCacheTimeoutNamedValue'))]",
"[resourceId('Microsoft.ApiManagement/service/namedValues', parameters('apimServiceName'), variables('aimSubscriptionIdNamedValue'))]"
],
"properties": {
"value": "<policies>\r\n <inbound>\r\n <base />\r\n <set-backend-service id=\"apim-generated-policy\" backend-id=\"aimroutingmanager\" />\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>",
"format": "xml"
}
},
{
"type": "Microsoft.ApiManagement/service/apis/operations/policies",
"apiVersion": "2019-12-01",
"name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'), '/getlogicappcallbackurl/policy')]",
"dependsOn": [
"[resourceId('Microsoft.ApiManagement/service/apis/operations', parameters('apimServiceName'), parameters('apiName'), 'getlogicappcallbackurl')]",
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), parameters('apiName'))]",
"[resourceId('Microsoft.ApiManagement/service/backends', parameters('apimServiceName'), parameters('apiName'))]",
"[resourceId('Microsoft.ApiManagement/service/namedValues', parameters('apimServiceName'), variables('aimCacheTimeoutNamedValue'))]",
"[resourceId('Microsoft.ApiManagement/service/namedValues', parameters('apimServiceName'), variables('aimSubscriptionIdNamedValue'))]"
],
"properties": {
"value": "<!--\r\n IMPORTANT:\r\n - Policy elements can appear only within the <inbound>, <outbound>, <backend> section elements.\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, place the cursor at the desired insertion point and select a policy from the sidebar.\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 - Comments within policy elements are not supported and may disappear. Place your comments between policy elements or at a higher level scope.\r\n-->\r\n<policies>\r\n <inbound>\r\n <set-variable name=\"resourceGroupName\" value=\"@(System.Net.WebUtility.UrlDecode(context.Request.MatchedParameters["resourceGroupName"]))\" />\r\n <set-variable name=\"logicAppName\" value=\"@(System.Net.WebUtility.UrlDecode(context.Request.MatchedParameters["logicAppName"]))\" />\r\n <set-variable name=\"cacheKey\" value=\"@("Cache:LogicAppCallbackUrl:" + context.Variables["resourceGroupName"] + ":" + context.Variables["logicAppName"])\" />\r\n <set-variable name=\"managementUrl\" value=\"@("https://management.azure.com/subscriptions/{{AIM-SubscriptionId}}/resourceGroups/" + context.Variables["resourceGroupName"] + "/providers/Microsoft.Logic/workflows/" + context.Variables["logicAppName"] + "/triggers/manual/listCallbackURL?api-version=2016-06-01")\" />\r\n <choose>\r\n <when condition=\"@(System.String.Compare(context.Request.OriginalUrl.Query.GetValueOrDefault("clearCache"), "true", true) == 0)\">\r\n <cache-remove-value key=\"@(context.Variables.GetValueOrDefault<string>("cacheKey"))\" caching-type=\"prefer-external\" />\r\n <set-variable name=\"managementResponse\" value=\"@(null)\" />\r\n </when>\r\n <otherwise>\r\n <cache-lookup-value key=\"@(context.Variables.GetValueOrDefault<string>("cacheKey"))\" variable-name=\"managementResponse\" caching-type=\"prefer-external\" />\r\n </otherwise>\r\n </choose>\r\n <choose>\r\n <when condition=\"@(context.Variables.GetValueOrDefault<IResponse>("managementResponse") == null)\">\r\n <send-request ignore-error=\"false\" timeout=\"20\" response-variable-name=\"managementResponse\" mode=\"new\">\r\n <set-url>@(context.Variables.GetValueOrDefault<string>(\"managementUrl\"))</set-url>\r\n <set-method>POST</set-method>\r\n <authentication-managed-identity resource=\"https://management.azure.com\" />\r\n </send-request>\r\n <choose>\r\n <when condition=\"@(((IResponse)context.Variables["managementResponse"]).Body == null)\">\r\n <cache-remove-value key=\"@(context.Variables.GetValueOrDefault<string>("cacheKey"))\" caching-type=\"prefer-external\" />\r\n <return-response>\r\n <set-status code=\"500\" reason=\"Internal Server Error\" />\r\n <set-body>@(\r\n new JObject(\r\n new JProperty(\"fault\", \r\n new JObject(\r\n new JProperty(\"faultActor\", context.Variables.GetValueOrDefault<string>(\"managementUrl\")),\r\n new JProperty(\"faultCode\", ((IResponse)context.Variables[\"managementResponse\"]).StatusCode),\r\n new JProperty(\"faultReason\",((IResponse)context.Variables[\"managementResponse\"]).StatusReason),\r\n new JProperty(\"faultCategory\", \"Error\"),\r\n new JProperty(\"faultMessage\", \"Found a CallbackUrl for this LogicApp but it is blank\")\r\n )\r\n )\r\n ).ToString()\r\n )</set-body>\r\n </return-response>\r\n </when>\r\n <when condition=\"@(((IResponse)context.Variables["managementResponse"]).StatusCode != 200)\">\r\n <cache-remove-value key=\"@(context.Variables.GetValueOrDefault<string>("cacheKey"))\" caching-type=\"prefer-external\" />\r\n <return-response>\r\n <set-status code=\"500\" reason=\"Internal Server Error\" />\r\n <set-header name=\"Content-Type\" exists-action=\"override\">\r\n <value>application/json</value>\r\n </set-header>\r\n <set-body>@{\r\n var additionalDetails = string.Empty;\r\n var internalFault = ((IResponse)context.Variables[\"managementResponse\"]).Body.As<JObject>();\r\n if (internalFault != null)\r\n {\r\n if (internalFault?[\"error\"] != null)\r\n {\r\n additionalDetails = \" Code: \" + ((string)internalFault?[\"error\"]?[\"code\"] ?? \"(unknown)\") + \", Error: \" + ((string)internalFault?[\"error\"]?[\"message\"] ?? \"(unknown)\");\r\n }\r\n else if (internalFault?[\"message\"] != null)\r\n {\r\n additionalDetails = \" Code: \" + ((string)internalFault?[\"code\"] ?? \"(unknown)\") + \", Error: \" + ((string)internalFault?[\"message\"] ?? \"(unknown)\");\r\n }\r\n }\r\n\r\n return new JObject(\r\n new JProperty(\"fault\", \r\n new JObject(\r\n new JProperty(\"faultActor\", context.Variables.GetValueOrDefault<string>(\"managementUrl\")),\r\n new JProperty(\"faultCode\", ((IResponse)context.Variables[\"managementResponse\"]).StatusCode),\r\n new JProperty(\"faultReason\",((IResponse)context.Variables[\"managementResponse\"]).StatusReason),\r\n new JProperty(\"faultCategory\", \"Error\"),\r\n new JProperty(\"faultMessage\", \"An error occurred trying to get a LogicApp CallBackUrl.\" + additionalDetails)\r\n )\r\n )\r\n ).ToString();\r\n }</set-body>\r\n </return-response>\r\n </when>\r\n <otherwise>\r\n <cache-store-value key=\"@(context.Variables.GetValueOrDefault<string>("cacheKey"))\" value=\"@((IResponse)context.Variables["managementResponse"])\" duration=\"{{AIM-CacheTimeout}}\" caching-type=\"prefer-external\" />\r\n </otherwise>\r\n </choose>\r\n </when>\r\n </choose>\r\n <choose>\r\n <when condition=\"@(((IResponse)context.Variables["managementResponse"]).StatusCode != 200)\">\r\n <return-response>\r\n <set-status code=\"500\" reason=\"Internal Server Error\" />\r\n <set-header name=\"Content-Type\" exists-action=\"override\">\r\n <value>application/json</value>\r\n </set-header>\r\n <set-body>@{\r\n var additionalDetails = string.Empty;\r\n var internalFault = ((IResponse)context.Variables[\"managementResponse\"]).Body.As<JObject>();\r\n if (internalFault != null)\r\n {\r\n if (internalFault?[\"error\"] != null)\r\n {\r\n additionalDetails = \" Code: \" + ((string)internalFault?[\"error\"]?[\"code\"] ?? \"(unknown)\") + \", Error: \" + ((string)internalFault?[\"error\"]?[\"message\"] ?? \"(unknown)\");\r\n }\r\n else if (internalFault?[\"message\"] != null)\r\n {\r\n additionalDetails = \" Code: \" + ((string)internalFault?[\"code\"] ?? \"(unknown)\") + \", Error: \" + ((string)internalFault?[\"message\"] ?? \"(unknown)\");\r\n }\r\n }\r\n\r\n return new JObject(\r\n new JProperty(\"fault\", \r\n new JObject(\r\n new JProperty(\"faultActor\", context.Variables.GetValueOrDefault<string>(\"managementUrl\")),\r\n new JProperty(\"faultCode\", ((IResponse)context.Variables[\"managementResponse\"]).StatusCode),\r\n new JProperty(\"faultReason\",((IResponse)context.Variables[\"managementResponse\"]).StatusReason),\r\n new JProperty(\"faultCategory\", \"Error\"),\r\n new JProperty(\"faultMessage\", \"An error occurred trying to get a LogicApp CallBackUrl.\" + additionalDetails)\r\n )\r\n )\r\n ).ToString();\r\n }</set-body>\r\n </return-response>\r\n </when>\r\n <otherwise>\r\n <return-response>\r\n <set-status code=\"200\" reason=\"OK\" />\r\n <set-header name=\"Content-Type\" exists-action=\"override\">\r\n <value>application/json</value>\r\n </set-header>\r\n <set-body>@(\r\n new JObject(\r\n new JProperty(\"logicAppUrl\",((IResponse)context.Variables[\"managementResponse\"]).Body.As<JObject>()[\"value\"])\r\n ).ToString()\r\n )</set-body>\r\n </return-response>\r\n </otherwise>\r\n </choose>\r\n <base />\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>",
"format": "xml"
}
},
{
"type": "Microsoft.ApiManagement/service/apis/operations/policies",
"apiVersion": "2019-12-01",
"name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'), '/getstandardlogicappcallbackurl/policy')]",
"dependsOn": [
"[resourceId('Microsoft.ApiManagement/service/apis/operations', parameters('apimServiceName'), parameters('apiName'), 'getstandardlogicappcallbackurl')]",
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), parameters('apiName'))]",
"[resourceId('Microsoft.ApiManagement/service/backends', parameters('apimServiceName'), parameters('apiName'))]",
"[resourceId('Microsoft.ApiManagement/service/namedValues', parameters('apimServiceName'), variables('aimCacheTimeoutNamedValue'))]",
"[resourceId('Microsoft.ApiManagement/service/namedValues', parameters('apimServiceName'), variables('aimSubscriptionIdNamedValue'))]"
],
"properties": {
"value": "<!--\r\n This policy will retrieve the CallBackUrl from the Azure Management API for a workflow within a given Standard Logic App.\r\n-->\r\n<policies>\r\n <inbound>\r\n <set-variable name=\"resourceGroupName\" value=\"@(System.Net.WebUtility.UrlDecode(context.Request.MatchedParameters["resourceGroupName"]))\" />\r\n <set-variable name=\"logicAppName\" value=\"@(System.Net.WebUtility.UrlDecode(context.Request.MatchedParameters["logicAppName"]))\" />\r\n <set-variable name=\"workflowName\" value=\"@(System.Net.WebUtility.UrlDecode(context.Request.MatchedParameters["workflowName"]))\" />\r\n <set-variable name=\"cacheKey\" value=\"@("Cache:LogicAppCallbackUrl:" + context.Variables["resourceGroupName"] + ":" + context.Variables["logicAppName"] + ":" + context.Variables["workflowName"])\" />\r\n <set-variable name=\"managementUrl\" value=\"@("https://management.azure.com/subscriptions/{{AIM-SubscriptionId}}/resourceGroups/" + context.Variables["resourceGroupName"] + "/providers/Microsoft.Web/sites/" + context.Variables["logicAppName"] + "/hostruntime/runtime/webhooks/workflow/api/management/workflows/" + context.Variables["workflowName"] + "/triggers/manual/listCallbackURL?api-version=2018-11-01")\" />\r\n <choose>\r\n <when condition=\"@(System.String.Compare(context.Request.OriginalUrl.Query.GetValueOrDefault("clearCache"), "true", true) == 0)\">\r\n <cache-remove-value key=\"@(context.Variables.GetValueOrDefault<string>("cacheKey"))\" caching-type=\"prefer-external\" />\r\n <set-variable name=\"managementResponse\" value=\"@(null)\" />\r\n </when>\r\n <otherwise>\r\n <cache-lookup-value key=\"@(context.Variables.GetValueOrDefault<string>("cacheKey"))\" variable-name=\"managementResponse\" caching-type=\"prefer-external\" />\r\n </otherwise>\r\n </choose>\r\n <choose>\r\n <when condition=\"@(context.Variables.GetValueOrDefault<IResponse>("managementResponse") == null)\">\r\n <send-request ignore-error=\"false\" timeout=\"20\" response-variable-name=\"managementResponse\" mode=\"new\">\r\n <set-url>@(context.Variables.GetValueOrDefault<string>(\"managementUrl\"))</set-url>\r\n <set-method>POST</set-method>\r\n <authentication-managed-identity resource=\"https://management.azure.com\" />\r\n </send-request>\r\n <choose>\r\n <when condition=\"@(((IResponse)context.Variables["managementResponse"]).Body == null)\">\r\n <cache-remove-value key=\"@(context.Variables.GetValueOrDefault<string>("cacheKey"))\" caching-type=\"prefer-external\" />\r\n <return-response>\r\n <set-status code=\"500\" reason=\"Internal Server Error\" />\r\n <set-body>@(\r\n new JObject(\r\n new JProperty(\"fault\", \r\n new JObject(\r\n new JProperty(\"faultActor\", context.Variables.GetValueOrDefault<string>(\"managementUrl\")),\r\n new JProperty(\"faultCode\", ((IResponse)context.Variables[\"managementResponse\"]).StatusCode),\r\n new JProperty(\"faultReason\",((IResponse)context.Variables[\"managementResponse\"]).StatusReason),\r\n new JProperty(\"faultCategory\", \"Error\"),\r\n new JProperty(\"faultMessage\", \"Found a CallbackUrl for this Standard LogicApp but it is blank\")\r\n )\r\n )\r\n ).ToString()\r\n )</set-body>\r\n </return-response>\r\n </when>\r\n <when condition=\"@(((IResponse)context.Variables["managementResponse"]).StatusCode != 200)\">\r\n <cache-remove-value key=\"@(context.Variables.GetValueOrDefault<string>("cacheKey"))\" caching-type=\"prefer-external\" />\r\n <return-response>\r\n <set-status code=\"500\" reason=\"Internal Server Error\" />\r\n <set-header name=\"Content-Type\" exists-action=\"override\">\r\n <value>application/json</value>\r\n </set-header>\r\n <set-body>@{\r\n var additionalDetails = string.Empty;\r\n var internalFault = ((IResponse)context.Variables[\"managementResponse\"]).Body.As<JObject>();\r\n if (internalFault != null)\r\n {\r\n if (internalFault?[\"error\"] != null)\r\n {\r\n additionalDetails = \" Code: \" + ((string)internalFault?[\"error\"]?[\"code\"] ?? \"(unknown)\") + \", Error: \" + ((string)internalFault?[\"error\"]?[\"message\"] ?? \"(unknown)\");\r\n }\r\n else if (internalFault?[\"message\"] != null)\r\n {\r\n additionalDetails = \" Code: \" + ((string)internalFault?[\"code\"] ?? \"(unknown)\") + \", Error: \" + ((string)internalFault?[\"message\"] ?? \"(unknown)\");\r\n }\r\n }\r\n\r\n return new JObject(\r\n new JProperty(\"fault\", \r\n new JObject(\r\n new JProperty(\"faultActor\", context.Variables.GetValueOrDefault<string>(\"managementUrl\")),\r\n new JProperty(\"faultCode\", ((IResponse)context.Variables[\"managementResponse\"]).StatusCode),\r\n new JProperty(\"faultReason\",((IResponse)context.Variables[\"managementResponse\"]).StatusReason),\r\n new JProperty(\"faultCategory\", \"Error\"),\r\n new JProperty(\"faultMessage\", \"An error occurred trying to get a Standard LogicApp CallBackUrl.\" + additionalDetails)\r\n )\r\n )\r\n ).ToString();\r\n }</set-body>\r\n </return-response>\r\n </when>\r\n <otherwise>\r\n <cache-store-value key=\"@(context.Variables.GetValueOrDefault<string>("cacheKey"))\" value=\"@((IResponse)context.Variables["managementResponse"])\" duration=\"{{AIM-CacheTimeout}}\" caching-type=\"prefer-external\" />\r\n </otherwise>\r\n </choose>\r\n </when>\r\n </choose>\r\n <choose>\r\n <when condition=\"@(((IResponse)context.Variables["managementResponse"]).StatusCode != 200)\">\r\n <return-response>\r\n <set-status code=\"500\" reason=\"Internal Server Error\" />\r\n <set-header name=\"Content-Type\" exists-action=\"override\">\r\n <value>application/json</value>\r\n </set-header>\r\n <set-body>@{\r\n var additionalDetails = string.Empty;\r\n var internalFault = ((IResponse)context.Variables[\"managementResponse\"]).Body.As<JObject>();\r\n if (internalFault != null)\r\n {\r\n if (internalFault?[\"error\"] != null)\r\n {\r\n additionalDetails = \" Code: \" + ((string)internalFault?[\"error\"]?[\"code\"] ?? \"(unknown)\") + \", Error: \" + ((string)internalFault?[\"error\"]?[\"message\"] ?? \"(unknown)\");\r\n }\r\n else if (internalFault?[\"message\"] != null)\r\n {\r\n additionalDetails = \" Code: \" + ((string)internalFault?[\"code\"] ?? \"(unknown)\") + \", Error: \" + ((string)internalFault?[\"message\"] ?? \"(unknown)\");\r\n }\r\n }\r\n\r\n return new JObject(\r\n new JProperty(\"fault\", \r\n new JObject(\r\n new JProperty(\"faultActor\", context.Variables.GetValueOrDefault<string>(\"managementUrl\")),\r\n new JProperty(\"faultCode\", ((IResponse)context.Variables[\"managementResponse\"]).StatusCode),\r\n new JProperty(\"faultReason\",((IResponse)context.Variables[\"managementResponse\"]).StatusReason),\r\n new JProperty(\"faultCategory\", \"Error\"),\r\n new JProperty(\"faultMessage\", \"An error occurred trying to get a Standard LogicApp CallBackUrl.\" + additionalDetails)\r\n )\r\n )\r\n ).ToString();\r\n }</set-body>\r\n </return-response>\r\n </when>\r\n <otherwise>\r\n <return-response>\r\n <set-status code=\"200\" reason=\"OK\" />\r\n <set-header name=\"Content-Type\" exists-action=\"override\">\r\n <value>application/json</value>\r\n </set-header>\r\n <set-body>@(\r\n new JObject(\r\n new JProperty(\"logicAppUrl\",((IResponse)context.Variables[\"managementResponse\"]).Body.As<JObject>()[\"value\"])\r\n ).ToString()\r\n )</set-body>\r\n </return-response>\r\n </otherwise>\r\n </choose>\r\n <base />\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>",
"format": "xml"
}
},
{
"type": "Microsoft.ApiManagement/service/namedValues",
"apiVersion": "2019-12-01",
"name": "[concat(parameters('apimServiceName'), '/', variables('aimCacheTimeoutNamedValue'))]",
"dependsOn": [
],
"properties": {
"displayName": "AIM-CacheTimeout",
"value": "[parameters('cacheTimeout')]",
"tags": [
],
"secret": false
}
},
{
"type": "Microsoft.ApiManagement/service/namedValues",
"apiVersion": "2019-12-01",
"name": "[concat(parameters('apimServiceName'), '/', variables('aimSubscriptionIdNamedValue'))]",
"dependsOn": [
],
"properties": {
"displayName": "AIM-SubscriptionId",
"tags": [
],
"secret": true,
"value": "[subscription().subscriptionId]"
}
},
{
"type": "Microsoft.ApiManagement/service/tags",
"apiVersion": "2019-12-01",
"name": "[concat(parameters('apimServiceName'), '/', variables('apiTagName'))]",
"dependsOn": [
],
"properties": {
"displayName": "routingmanager"
}
}
]
}