Skip to content

Commit 9ece430

Browse files
author
Kay Singh
committedSep 30, 2019
Added code for logic apps
1 parent d5b45ad commit 9ece430

File tree

2 files changed

+816
-0
lines changed

2 files changed

+816
-0
lines changed
 

‎logic-apps/encoding-logic-app.json

+523
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,523 @@
1+
{
2+
"$connections": {
3+
"value": {
4+
"aci": {
5+
"connectionId": "/subscriptions/<sub-id>/resourceGroups/serverless-encoder-rg/providers/Microsoft.Web/connections/aci",
6+
"connectionName": "aci",
7+
"id": "/subscriptions/<sub-id>/providers/Microsoft.Web/locations/westus2/managedApis/aci"
8+
},
9+
"azurefile": {
10+
"connectionId": "/subscriptions/<sub-id>/resourceGroups/serverless-encoder-rg/providers/Microsoft.Web/connections/azurefile",
11+
"connectionName": "azurefile",
12+
"id": "/subscriptions/<sub-id>/providers/Microsoft.Web/locations/westus2/managedApis/azurefile"
13+
},
14+
"outlook": {
15+
"connectionId": "/subscriptions/<sub-id>/resourceGroups/serverless-encoder-rg/providers/Microsoft.Web/connections/outlook",
16+
"connectionName": "outlook",
17+
"id": "/subscriptions/<sub-id>/providers/Microsoft.Web/locations/westus2/managedApis/outlook"
18+
},
19+
"videoindexer-v2": {
20+
"connectionId": "/subscriptions/<sub-id>/resourceGroups/serverless-encoder-rg/providers/Microsoft.Web/connections/videoindexer-v2",
21+
"connectionName": "videoindexer-v2",
22+
"id": "/subscriptions/<sub-id>/providers/Microsoft.Web/locations/westus2/managedApis/videoindexer-v2"
23+
}
24+
}
25+
},
26+
"definition": {
27+
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
28+
"actions": {
29+
"Create_container_group_2": {
30+
"inputs": {
31+
"body": {
32+
"location": "westus2",
33+
"properties": {
34+
"containers": [
35+
{
36+
"name": "concat-ffmpeg",
37+
"properties": {
38+
"command": [
39+
"/opt/ffmpeg/bin/ffmpeg",
40+
"-f",
41+
"concat",
42+
"-safe",
43+
"0",
44+
"-i",
45+
"/aci/insights/@{body('Create_file_2')?['Name']}",
46+
"-c",
47+
"copy",
48+
"-y",
49+
"/aci/output/@{body('Get_Video_Index')?['name']}-output.mkv"
50+
],
51+
"image": "offbytwo/ffmpeg",
52+
"resources": {
53+
"requests": {
54+
"cpu": 2,
55+
"memoryInGB": 1.5
56+
}
57+
},
58+
"volumeMounts": [
59+
{
60+
"mountPath": "/aci/insights/",
61+
"name": "insights",
62+
"readOnly": true
63+
},
64+
{
65+
"mountPath": "/aci/shots/",
66+
"name": "shots",
67+
"readOnly": true
68+
},
69+
{
70+
"mountPath": "/aci/output/",
71+
"name": "output",
72+
"readOnly": false
73+
}
74+
]
75+
}
76+
}
77+
],
78+
"osType": "Linux",
79+
"restartPolicy": "Never",
80+
"volumes": [
81+
{
82+
"azureFile": {
83+
"readOnly": true,
84+
"shareName": "shots",
85+
"storageAccountKey": "",
86+
"storageAccountName": "serverlessencodermedia"
87+
},
88+
"name": "shots"
89+
},
90+
{
91+
"azureFile": {
92+
"readOnly": true,
93+
"shareName": "insights",
94+
"storageAccountKey": "",
95+
"storageAccountName": "serverlessencodermedia"
96+
},
97+
"name": "insights"
98+
},
99+
{
100+
"azureFile": {
101+
"readOnly": false,
102+
"shareName": "output",
103+
"storageAccountKey": "",
104+
"storageAccountName": "serverlessencodermedia"
105+
},
106+
"name": "output"
107+
}
108+
]
109+
}
110+
},
111+
"host": {
112+
"connection": {
113+
"name": "@parameters('$connections')['aci']['connectionId']"
114+
}
115+
},
116+
"method": "put",
117+
"path": "/subscriptions/@{encodeURIComponent('<sub-id>')}/resourceGroups/@{encodeURIComponent('serverless-encoder-rg')}/providers/Microsoft.ContainerInstance/containerGroups/@{encodeURIComponent('concat-ffmpeg')}",
118+
"queries": {
119+
"x-ms-api-version": "2017-10-01-preview"
120+
}
121+
},
122+
"runAfter": {
123+
"Create_file_2": [
124+
"Succeeded"
125+
]
126+
},
127+
"type": "ApiConnection"
128+
},
129+
"Create_file": {
130+
"inputs": {
131+
"body": "@body('Get_Video_Index')?['videos'][0]['insights']['shots']",
132+
"host": {
133+
"connection": {
134+
"name": "@parameters('$connections')['azurefile']['connectionId']"
135+
}
136+
},
137+
"method": "post",
138+
"path": "/datasets/default/files",
139+
"queries": {
140+
"folderPath": "/insights",
141+
"name": "@{concat(body('Get_Video_Index')?['name'], '-insights','.json')}",
142+
"queryParametersSingleEncoded": true
143+
}
144+
},
145+
"runAfter": {
146+
"Get_Video_Index": [
147+
"Succeeded"
148+
]
149+
},
150+
"runtimeConfiguration": {
151+
"contentTransfer": {
152+
"transferMode": "Chunked"
153+
}
154+
},
155+
"type": "ApiConnection"
156+
},
157+
"Create_file_2": {
158+
"inputs": {
159+
"body": "@body('ffmpeg-concat')",
160+
"host": {
161+
"connection": {
162+
"name": "@parameters('$connections')['azurefile']['connectionId']"
163+
}
164+
},
165+
"method": "post",
166+
"path": "/datasets/default/files",
167+
"queries": {
168+
"folderPath": "/insights",
169+
"name": "@{concat(body('Get_Video_Index')?['name'],'-concat','.txt')}",
170+
"queryParametersSingleEncoded": true
171+
}
172+
},
173+
"runAfter": {
174+
"ffmpeg-concat": [
175+
"Succeeded"
176+
]
177+
},
178+
"runtimeConfiguration": {
179+
"contentTransfer": {
180+
"transferMode": "Chunked"
181+
}
182+
},
183+
"type": "ApiConnection"
184+
},
185+
"For_each": {
186+
"actions": {
187+
"Create_container_group": {
188+
"inputs": {
189+
"body": {
190+
"location": "westus2",
191+
"properties": {
192+
"containers": [
193+
"@items('For_each')"
194+
],
195+
"osType": "Linux",
196+
"restartPolicy": "Never",
197+
"volumes": [
198+
{
199+
"azureFile": {
200+
"readOnly": false,
201+
"shareName": "source",
202+
"storageAccountKey": "",
203+
"storageAccountName": "serverlessncodermedia"
204+
},
205+
"name": "source"
206+
},
207+
{
208+
"azureFile": {
209+
"readOnly": false,
210+
"shareName": "shots",
211+
"storageAccountKey": "",
212+
"storageAccountName": "serverlessncodermedia"
213+
},
214+
"name": "shots"
215+
}
216+
]
217+
}
218+
},
219+
"host": {
220+
"connection": {
221+
"name": "@parameters('$connections')['aci']['connectionId']"
222+
}
223+
},
224+
"method": "put",
225+
"path": "/subscriptions/@{encodeURIComponent('<sub-id>')}/resourceGroups/@{encodeURIComponent('encoding-containers-rg')}/providers/Microsoft.ContainerInstance/containerGroups/@{encodeURIComponent(items('For_each')?[0]['name'])}",
226+
"queries": {
227+
"x-ms-api-version": "2017-10-01-preview"
228+
}
229+
},
230+
"runAfter": {},
231+
"type": "ApiConnection"
232+
},
233+
"Delete_container_group": {
234+
"inputs": {
235+
"host": {
236+
"connection": {
237+
"name": "@parameters('$connections')['aci']['connectionId']"
238+
}
239+
},
240+
"method": "delete",
241+
"path": "/subscriptions/@{encodeURIComponent('<sub-id>')}/resourceGroups/@{encodeURIComponent('encoding-containers-rg')}/providers/Microsoft.ContainerInstance/containerGroups/@{encodeURIComponent(items('For_each')?[0]['name'])}",
242+
"queries": {
243+
"x-ms-api-version": "2017-10-01-preview"
244+
}
245+
},
246+
"runAfter": {
247+
"Until_2": [
248+
"Succeeded"
249+
]
250+
},
251+
"type": "ApiConnection"
252+
},
253+
"Until": {
254+
"actions": {
255+
"Delay": {
256+
"inputs": {
257+
"interval": {
258+
"count": 1,
259+
"unit": "Minute"
260+
}
261+
},
262+
"runAfter": {},
263+
"type": "Wait"
264+
},
265+
"Get_properties_of_a_container_group": {
266+
"inputs": {
267+
"host": {
268+
"connection": {
269+
"name": "@parameters('$connections')['aci']['connectionId']"
270+
}
271+
},
272+
"method": "get",
273+
"path": "/subscriptions/@{encodeURIComponent('<sub-id>')}/resourceGroups/@{encodeURIComponent('encoding-containers-rg')}/providers/Microsoft.ContainerInstance/containerGroups/@{encodeURIComponent(items('For_each')?[0]['name'])}",
274+
"queries": {
275+
"x-ms-api-version": "2017-10-01-preview"
276+
}
277+
},
278+
"runAfter": {
279+
"Delay": [
280+
"Succeeded"
281+
]
282+
},
283+
"type": "ApiConnection"
284+
}
285+
},
286+
"expression": "@equals(body('Get_properties_of_a_container_group')?['properties']?['provisioningState'], 'Succeeded')",
287+
"limit": {
288+
"count": 60,
289+
"timeout": "PT1H"
290+
},
291+
"runAfter": {
292+
"Create_container_group": [
293+
"Succeeded"
294+
]
295+
},
296+
"type": "Until"
297+
},
298+
"Until_2": {
299+
"actions": {
300+
"Delay_2": {
301+
"inputs": {
302+
"interval": {
303+
"count": 2,
304+
"unit": "Minute"
305+
}
306+
},
307+
"runAfter": {},
308+
"type": "Wait"
309+
},
310+
"Get_properties_of_a_container_group_2": {
311+
"inputs": {
312+
"host": {
313+
"connection": {
314+
"name": "@parameters('$connections')['aci']['connectionId']"
315+
}
316+
},
317+
"method": "get",
318+
"path": "/subscriptions/@{encodeURIComponent('<sub-id>')}/resourceGroups/@{encodeURIComponent('encoding-containers-rg')}/providers/Microsoft.ContainerInstance/containerGroups/@{encodeURIComponent(items('For_each')?[0]['name'])}",
319+
"queries": {
320+
"x-ms-api-version": "2017-10-01-preview"
321+
}
322+
},
323+
"runAfter": {
324+
"Delay_2": [
325+
"Succeeded"
326+
]
327+
},
328+
"type": "ApiConnection"
329+
}
330+
},
331+
"expression": "@equals(body('Get_properties_of_a_container_group_2')?['properties']?['instanceView']?['state'], '')",
332+
"limit": {
333+
"count": 60,
334+
"timeout": "PT1H"
335+
},
336+
"runAfter": {
337+
"Until": [
338+
"Succeeded"
339+
]
340+
},
341+
"type": "Until"
342+
}
343+
},
344+
"foreach": "@json(body('parse-shots'))",
345+
"runAfter": {
346+
"parse-shots": [
347+
"Succeeded"
348+
]
349+
},
350+
"runtimeConfiguration": {
351+
"concurrency": {
352+
"repetitions": 50
353+
}
354+
},
355+
"type": "Foreach"
356+
},
357+
"Get_Account_Access_Token": {
358+
"inputs": {
359+
"host": {
360+
"connection": {
361+
"name": "@parameters('$connections')['videoindexer-v2']['connectionId']"
362+
}
363+
},
364+
"method": "get",
365+
"path": "/auth/@{encodeURIComponent('westus2')}/Accounts/@{encodeURIComponent('<access-token>')}/AccessToken",
366+
"queries": {
367+
"allowEdit": false
368+
}
369+
},
370+
"runAfter": {},
371+
"type": "ApiConnection"
372+
},
373+
"Get_Video_Index": {
374+
"inputs": {
375+
"host": {
376+
"connection": {
377+
"name": "@parameters('$connections')['videoindexer-v2']['connectionId']"
378+
}
379+
},
380+
"method": "get",
381+
"path": "/@{encodeURIComponent('westus2')}/Accounts/@{encodeURIComponent('<access-token>')}/Videos/@{encodeURIComponent(triggerOutputs()['queries']['id'])}/Index",
382+
"queries": {
383+
"accessToken": "@body('Get_Account_Access_Token')"
384+
}
385+
},
386+
"runAfter": {
387+
"Get_Account_Access_Token": [
388+
"Succeeded"
389+
]
390+
},
391+
"type": "ApiConnection"
392+
},
393+
"Send_an_email_(V2)": {
394+
"inputs": {
395+
"body": {
396+
"Body": "<p>Video file name: /aci/output/@{body('Get_Video_Index')?['name']}-output.mkv</p>",
397+
"Subject": "Encoded video now available",
398+
"To": "<email-to-send-completed-notification-to>"
399+
},
400+
"host": {
401+
"connection": {
402+
"name": "@parameters('$connections')['outlook']['connectionId']"
403+
}
404+
},
405+
"method": "post",
406+
"path": "/v2/Mail"
407+
},
408+
"runAfter": {
409+
"Until_3": [
410+
"Succeeded"
411+
]
412+
},
413+
"type": "ApiConnection"
414+
},
415+
"Until_3": {
416+
"actions": {
417+
"Delay_3": {
418+
"inputs": {
419+
"interval": {
420+
"count": 1,
421+
"unit": "Minute"
422+
}
423+
},
424+
"runAfter": {},
425+
"type": "Wait"
426+
},
427+
"Get_properties_of_a_container_group_3": {
428+
"inputs": {
429+
"host": {
430+
"connection": {
431+
"name": "@parameters('$connections')['aci']['connectionId']"
432+
}
433+
},
434+
"method": "get",
435+
"path": "/subscriptions/@{encodeURIComponent('<sub-id>')}/resourceGroups/@{encodeURIComponent('serverless-encoder-rg')}/providers/Microsoft.ContainerInstance/containerGroups/@{encodeURIComponent(body('Create_container_group_2')?['name'])}",
436+
"queries": {
437+
"x-ms-api-version": "2017-10-01-preview"
438+
}
439+
},
440+
"runAfter": {
441+
"Delay_3": [
442+
"Succeeded"
443+
]
444+
},
445+
"type": "ApiConnection"
446+
}
447+
},
448+
"expression": "@equals(body('Get_properties_of_a_container_group_3')?['properties']?['instanceView']?['state'], '')",
449+
"limit": {
450+
"count": 60,
451+
"timeout": "PT1H"
452+
},
453+
"runAfter": {
454+
"Create_container_group_2": [
455+
"Succeeded"
456+
]
457+
},
458+
"type": "Until"
459+
},
460+
"ffmpeg-concat": {
461+
"inputs": {
462+
"body": "@body('Get_Video_Index')?['videos'][0]['insights']['shots']",
463+
"function": {
464+
"id": "/subscriptions/<sub-id>/resourceGroups/serverless-encoder-rg/providers/Microsoft.Web/sites/serverless-encoder-functions/functions/ffmpeg-concat"
465+
},
466+
"headers": {
467+
"Content-Type": "application/json",
468+
"aciShotsVideoPath": "/aci/shots/"
469+
}
470+
},
471+
"runAfter": {
472+
"For_each": [
473+
"Succeeded"
474+
]
475+
},
476+
"type": "Function"
477+
},
478+
"parse-shots": {
479+
"inputs": {
480+
"body": "@body('Get_Video_Index')?['videos'][0]['insights']['shots']",
481+
"function": {
482+
"id": "/subscriptions/<sub-id>/resourceGroups/serverless-encoder-rg/providers/Microsoft.Web/sites/serverless-encoder-functions/functions/parse-shots"
483+
},
484+
"headers": {
485+
"Content-Type": "application/json",
486+
"aciDestinationVideoMountName": "shots",
487+
"aciDestinationVideoPath": "/aci/shots/",
488+
"aciSourceVideoMountName": "source",
489+
"aciSourceVideoPath": "/aci/source/",
490+
"dockerImage": "singhkays/ffmpeg-av1-libaom",
491+
"ffmpegBinaryPath": "/opt/ffmpeg/bin",
492+
"requestedCPUCores": "2",
493+
"requestedMemoryInGB": "2",
494+
"videoName": "@body('Get_Video_Index')?['name']"
495+
}
496+
},
497+
"runAfter": {
498+
"Create_file": [
499+
"Succeeded"
500+
]
501+
},
502+
"type": "Function"
503+
}
504+
},
505+
"contentVersion": "1.0.0.0",
506+
"outputs": {},
507+
"parameters": {
508+
"$connections": {
509+
"defaultValue": {},
510+
"type": "Object"
511+
}
512+
},
513+
"triggers": {
514+
"manual": {
515+
"inputs": {
516+
"schema": {}
517+
},
518+
"kind": "Http",
519+
"type": "Request"
520+
}
521+
}
522+
}
523+
}
+293
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,293 @@
1+
{
2+
"$connections": {
3+
"value": {
4+
"aci": {
5+
"connectionId": "/subscriptions/<sub-id>/resourceGroups/serverless-encoder-rg/providers/Microsoft.Web/connections/aci",
6+
"connectionName": "aci",
7+
"id": "/subscriptions/<sub-id>/providers/Microsoft.Web/locations/westus2/managedApis/aci"
8+
},
9+
"azureblob": {
10+
"connectionId": "/subscriptions/<sub-id>/resourceGroups/serverless-encoder-rg/providers/Microsoft.Web/connections/azureblob",
11+
"connectionName": "azureblob",
12+
"id": "/subscriptions/<sub-id>/providers/Microsoft.Web/locations/westus2/managedApis/azureblob"
13+
},
14+
"azureeventgrid": {
15+
"connectionId": "/subscriptions/<sub-id>/resourceGroups/serverless-encoder-rg/providers/Microsoft.Web/connections/azureeventgrid",
16+
"connectionName": "azureeventgrid",
17+
"id": "/subscriptions/<sub-id>/providers/Microsoft.Web/locations/westus2/managedApis/azureeventgrid"
18+
},
19+
"videoindexer-v2": {
20+
"connectionId": "/subscriptions/<sub-id>/resourceGroups/serverless-encoder-rg/providers/Microsoft.Web/connections/videoindexer-v2",
21+
"connectionName": "videoindexer-v2",
22+
"id": "/subscriptions/<sub-id>/providers/Microsoft.Web/locations/westus2/managedApis/videoindexer-v2"
23+
}
24+
}
25+
},
26+
"definition": {
27+
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
28+
"actions": {
29+
"Condition": {
30+
"actions": {
31+
"Compose": {
32+
"inputs": "@{split(triggerBody()?['subject'], '/')?[4]}/@{split(triggerBody()?['subject'], '/')?[6]}",
33+
"runAfter": {},
34+
"type": "Compose"
35+
},
36+
"Create_SAS_URI_by_path": {
37+
"inputs": {
38+
"body": {
39+
"Permissions": "Read"
40+
},
41+
"host": {
42+
"connection": {
43+
"name": "@parameters('$connections')['azureblob']['connectionId']"
44+
}
45+
},
46+
"method": "post",
47+
"path": "/datasets/default/CreateSharedLinkByPath",
48+
"queries": {
49+
"path": "@{outputs('Compose')}"
50+
}
51+
},
52+
"runAfter": {
53+
"Compose": [
54+
"Succeeded"
55+
]
56+
},
57+
"type": "ApiConnection"
58+
},
59+
"Create_container_group": {
60+
"inputs": {
61+
"body": {
62+
"location": "westus2",
63+
"properties": {
64+
"containers": [
65+
{
66+
"name": "@body('Upload_video_and_index')?['id']",
67+
"properties": {
68+
"command": [
69+
"wget",
70+
"--no-check-certificate",
71+
"-O",
72+
"/aci/source/@{split(triggerBody()?['subject'], '/')?[6]}",
73+
"@body('Create_SAS_URI_by_path')?['WebUrl']"
74+
],
75+
"image": "inutano/wget",
76+
"resources": {
77+
"requests": {
78+
"cpu": 1,
79+
"memoryInGB": 0.5
80+
}
81+
},
82+
"volumeMounts": [
83+
{
84+
"mountPath": "/aci/source/",
85+
"name": "source",
86+
"readOnly": false
87+
}
88+
]
89+
}
90+
}
91+
],
92+
"osType": "Linux",
93+
"restartPolicy": "Never",
94+
"volumes": [
95+
{
96+
"azureFile": {
97+
"readOnly": false,
98+
"shareName": "source",
99+
"storageAccountKey": "",
100+
"storageAccountName": "serverlessncodermedia"
101+
},
102+
"name": "source"
103+
}
104+
]
105+
}
106+
},
107+
"host": {
108+
"connection": {
109+
"name": "@parameters('$connections')['aci']['connectionId']"
110+
}
111+
},
112+
"method": "put",
113+
"path": "/subscriptions/@{encodeURIComponent('<sub-id>')}/resourceGroups/@{encodeURIComponent('encoding-containers-rg')}/providers/Microsoft.ContainerInstance/containerGroups/@{encodeURIComponent(body('Upload_video_and_index')?['id'])}",
114+
"queries": {
115+
"x-ms-api-version": "2017-10-01-preview"
116+
}
117+
},
118+
"runAfter": {
119+
"Upload_video_and_index": [
120+
"Succeeded"
121+
]
122+
},
123+
"type": "ApiConnection"
124+
},
125+
"Delete_container_group": {
126+
"inputs": {
127+
"host": {
128+
"connection": {
129+
"name": "@parameters('$connections')['aci']['connectionId']"
130+
}
131+
},
132+
"method": "delete",
133+
"path": "/subscriptions/@{encodeURIComponent('<sub-id>')}/resourceGroups/@{encodeURIComponent('encoding-containers-rg')}/providers/Microsoft.ContainerInstance/containerGroups/@{encodeURIComponent(body('Get_properties_of_a_container_group')?['name'])}",
134+
"queries": {
135+
"x-ms-api-version": "2017-10-01-preview"
136+
}
137+
},
138+
"runAfter": {
139+
"Until": [
140+
"Succeeded"
141+
]
142+
},
143+
"type": "ApiConnection"
144+
},
145+
"Get_Account_Access_Token": {
146+
"inputs": {
147+
"host": {
148+
"connection": {
149+
"name": "@parameters('$connections')['videoindexer-v2']['connectionId']"
150+
}
151+
},
152+
"method": "get",
153+
"path": "/auth/@{encodeURIComponent('westus2')}/Accounts/@{encodeURIComponent('<access-token>')}/AccessToken",
154+
"queries": {
155+
"allowEdit": true
156+
}
157+
},
158+
"runAfter": {
159+
"Create_SAS_URI_by_path": [
160+
"Succeeded"
161+
]
162+
},
163+
"type": "ApiConnection"
164+
},
165+
"Until": {
166+
"actions": {
167+
"Delay": {
168+
"inputs": {
169+
"interval": {
170+
"count": 1,
171+
"unit": "Minute"
172+
}
173+
},
174+
"runAfter": {},
175+
"type": "Wait"
176+
},
177+
"Get_properties_of_a_container_group": {
178+
"inputs": {
179+
"host": {
180+
"connection": {
181+
"name": "@parameters('$connections')['aci']['connectionId']"
182+
}
183+
},
184+
"method": "get",
185+
"path": "/subscriptions/@{encodeURIComponent('<sub-id>')}/resourceGroups/@{encodeURIComponent('encoding-containers-rg')}/providers/Microsoft.ContainerInstance/containerGroups/@{encodeURIComponent(body('Create_container_group')?['name'])}",
186+
"queries": {
187+
"x-ms-api-version": "2017-10-01-preview"
188+
}
189+
},
190+
"runAfter": {
191+
"Delay": [
192+
"Succeeded"
193+
]
194+
},
195+
"type": "ApiConnection"
196+
}
197+
},
198+
"expression": "@equals(body('Get_properties_of_a_container_group')?['properties']?['instanceView']?['state'], 'Succeeded')",
199+
"limit": {
200+
"count": 60,
201+
"timeout": "PT1H"
202+
},
203+
"runAfter": {
204+
"Create_container_group": [
205+
"Succeeded"
206+
]
207+
},
208+
"type": "Until"
209+
},
210+
"Upload_video_and_index": {
211+
"inputs": {
212+
"host": {
213+
"connection": {
214+
"name": "@parameters('$connections')['videoindexer-v2']['connectionId']"
215+
}
216+
},
217+
"method": "post",
218+
"path": "/@{encodeURIComponent('westus2')}/Accounts/@{encodeURIComponent('<access-token>')}/Videos",
219+
"queries": {
220+
"accessToken": "@body('Get_Account_Access_Token')",
221+
"callbackUrl": "<call-back-URL-for-encoding-logic-app>",
222+
"fileName": "@{split(triggerBody()?['subject'], '/')?[6]}",
223+
"name": "@{split(triggerBody()?['subject'], '/')?[6]}",
224+
"videoUrl": "@body('Create_SAS_URI_by_path')?['WebUrl']"
225+
}
226+
},
227+
"runAfter": {
228+
"Get_Account_Access_Token": [
229+
"Succeeded"
230+
]
231+
},
232+
"type": "ApiConnection"
233+
}
234+
},
235+
"expression": {
236+
"and": [
237+
{
238+
"equals": [
239+
"@triggerBody()?['eventType']",
240+
"Microsoft.Storage.BlobCreated"
241+
]
242+
}
243+
]
244+
},
245+
"runAfter": {},
246+
"type": "If"
247+
}
248+
},
249+
"contentVersion": "1.0.0.0",
250+
"outputs": {},
251+
"parameters": {
252+
"$connections": {
253+
"defaultValue": {},
254+
"type": "Object"
255+
}
256+
},
257+
"triggers": {
258+
"When_a_resource_event_occurs": {
259+
"inputs": {
260+
"body": {
261+
"properties": {
262+
"destination": {
263+
"endpointType": "webhook",
264+
"properties": {
265+
"endpointUrl": "@{listCallbackUrl()}"
266+
}
267+
},
268+
"filter": {
269+
"includedEventTypes": [
270+
"Microsoft.Storage.BlobCreated"
271+
],
272+
"subjectEndsWith": ".mp4"
273+
},
274+
"topic": "/subscriptions/<sub-id>/resourceGroups/serverless-encoder-rg/providers/Microsoft.Storage/storageAccounts/serverlessncodermedia"
275+
}
276+
},
277+
"host": {
278+
"connection": {
279+
"name": "@parameters('$connections')['azureeventgrid']['connectionId']"
280+
}
281+
},
282+
"path": "/subscriptions/<sub-id>/providers/@{encodeURIComponent('Microsoft.Storage.StorageAccounts')}/resource/eventSubscriptions",
283+
"queries": {
284+
"subscriptionName": "mediaupload-sub",
285+
"x-ms-api-version": "2017-09-15-preview"
286+
}
287+
},
288+
"splitOn": "@triggerBody()",
289+
"type": "ApiConnectionWebhook"
290+
}
291+
}
292+
}
293+
}

0 commit comments

Comments
 (0)
Please sign in to comment.