%3CLINGO-SUB%20id%3D%22lingo-sub-1595464%22%20slang%3D%22en-US%22%3ECreating%20an%20Media%20Upload%20Workflow%20using%20Azure%20Storage%2C%20Logic%20Apps%20and%20Media%20Services%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1595464%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EOver%20the%20last%20two%20months%2C%20I%E2%80%99ve%20engaged%20with%20a%20few%20media%20companies%20who%20wanted%20to%20learn%20how%20to%20integrate%20Azure%20Media%20Services%20into%20their%20workflow.%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fservices%2Fmedia-services%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Media%20Services%20(AMS)%3C%2FA%3E%3CSPAN%3E%26nbsp%3Boffers%20a%20whole%20range%20of%20media%20capabilities%20for%20content%20ingest%2C%20storage%2C%20transcoding%2C%20video%20AI%2C%20encryption%2C%20dynamic%20packaging%2C%20and%20delivery%20%E2%80%93%20be%20it%20for%20live%20streaming%20or%20VOD%20through%20a%20single%20or%20multi-CDN.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2220200529-MediaUploadWorkflow-AzureMediaServices%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F213023i02F3CEC330B7B421%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%2220200529-MediaUploadWorkflow-AzureMediaServices%22%20alt%3D%2220200529-MediaUploadWorkflow-AzureMediaServices%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20post%20contains%202%20sample%20workflow%20implementations%20for%20content%20ingest%20and%20clear%20stream%20publishing%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EA%20logic%20app%20that%20monitors%20newly%20uploaded%20content%20in%20an%20Azure%20Storage%20for%20transcoding%20and%20indexing.%3C%2FLI%3E%0A%3CLI%3EA%20logic%20app%20for%20publishing%20a%20media%20asset%20with%20a%20clear%20stream%20locator.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1293485071%22%20id%3D%22toc-hId--1293485071%22%3EReference%20and%20Set-up%3C%2FH2%3E%0A%3CP%3EBefore%20I%20start%2C%20let%20me%20just%20share%20first%20that%20I%20referred%20to%20these%202%20GitHub%20Repos%20extensively%20in%20implementing%20this%20logic%20app%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure-Samples%2Fmedia-services-dotnet-functions-integration%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FAzure-Samples%2Fmedia-services-dotnet-functions-integration%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure-Samples%2Fmedia-services-v3-dotnet-core-functions-integration%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FAzure-Samples%2Fmedia-services-v3-dotnet-core-functions-integration%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EIn%20doing%20so%2C%20I%20had%20to%20refactor%20some%20functions%20and%20split%20them%20into%20two.%20I%20also%20had%20to%20add%20some%20more%20functions%20to%20suit%20my%20needs.%20So%20I%20forked%20the%20v3%20repository%2C%20which%20you%20can%20check%20out%20here%3A%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fraffertyuy%2Fmedia-services-v3-dotnet-core-functions-integration%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fraffertyuy%2Fmedia-services-v3-dotnet-core-functions-integration%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3ECreate%20an%20Azure%20Function%20App%20and%20deploy%20the%20functions%20found%20in%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fraffertyuy%2Fmedia-services-v3-dotnet-core-functions-integration%2Ftree%2Fmaster%2Fadvanced-vod-workflow%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eadvanced-vod-workflow%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Efolder.%3C%2FP%3E%0A%3CP%3EAlso%2C%20if%20you%20prefer%20to%20skip%20reading%20the%20logic%20app%20documentation%20below%2C%20feel%20free%20to%20clone%20the%20repo%20above%20and%20go%20straight%20to%20the%20code.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1194027762%22%20id%3D%22toc-hId-1194027762%22%3EUpload%20and%20Process%20Workflow%3C%2FH2%3E%0A%3CP%3EMedia%20companies%20will%20have%20an%20existing%20process%20for%20the%20creation%20of%20mezzanine%20files.%20These%20files%20are%20then%20typically%20uploaded%20to%20a%20CDN%20for%20content%20distribution.%20Given%20that%20this%20process%20already%20exists%2C%20the%20idea%20here%20is%20to%20add%2Fmodify%20the%20upload%20destination%20to%20an%20Azure%20Storage%20instead%20and%20expect%20it%20to%20be%20processed%20in%20Azure%20Media%20Services.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1884589236%22%20id%3D%22toc-hId-1884589236%22%3EMedia%20Service%20Assets%3C%2FH3%3E%0A%3CP%3EAn%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fmedia-services%2Flatest%2Fassets-concept%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAsset%3C%2FA%3E%26nbsp%3Bis%20a%20core%20concept%20specific%20to%20Azure%20Media%20Services%20(AMS).%20It%20is%20not%20a%20single%20blob%20in%20Azure%20Storage.%20An%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CEM%3Easset%3C%2FEM%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Efrom%20a%20storage%20perspective%20will%20contain%20multiple%20files%2C%20such%20as%20its%20metadata%2C%20multiple%20bitrate%20files%2C%20etc.%20Internally%2C%20AMS%20handles%20this%20by%20mapping%20each%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CEM%3Easset%3C%2FEM%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%20an%20Azure%20Blob%20container%2C%20which%20contains%20all%20of%20these%20files.%3C%2FP%3E%0A%3CP%3ESo%20the%20main%20challenge%20is%20how%20to%20upload%20a%20mezzanine%20file%20and%20get%20it%20recognized%20as%20a%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CEM%3Emedia%20asset%3C%2FEM%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eby%20Azure%20Media%20Services%2C%20and%20this%20is%20where%20logic%20apps%20come%20in.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-77134773%22%20id%3D%22toc-hId-77134773%22%3EThe%20Logic%20App%3C%2FH3%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fservices%2Flogic-apps%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Logic%20Apps%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eis%20a%20cloud%20service%20that%20helps%20you%20schedule%2C%20automate%2C%20and%20orchestrate%20tasks%2C%20business%20processes%2C%20and%20workflows%20when%20you%20need%20to%20integrate%20apps%2C%20data%2C%20systems%2C%20and%20services%20across%20enterprises%20or%20organizations.%20In%20this%20particular%20case%2C%20we%20are%20using%20logic%20apps%20to%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EMonitor%20an%20Azure%20Storage%20account%20for%20new%20uploads%3C%2FLI%3E%0A%3CLI%3ECreate%20an%20Asset%20in%20Azure%20Media%20Services%3C%2FLI%3E%0A%3CLI%3ETranscode%20the%20asset%20into%20multi-bitrate%3C%2FLI%3E%0A%3CLI%3ESend%20to%20Azure%20Video%20Indexer%20for%20Video%20AI%20insights%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3EIn%20implementing%20this%20logic%20app%2C%20I%20used%20a%20lot%20of%20connectors%2C%20including%20a%20connector%20to%20Azure%20Functions.%20I%20used%20Azure%20functions%20to%20execute%20code%20that%20is%20not%20available%20in%20Logic%20Apps.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId-767696247%22%20id%3D%22toc-hId-767696247%22%3EMonitor%20an%20Azure%20Storage%20Account%20for%20New%20Uploads%3C%2FH4%3E%0A%3CP%3EThis%20one%20is%20easy%3B%20I%20used%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fconnectors%2Fazureblob%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Blob%20Storage%20trigger%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%20monitor%20for%20new%20files%20uploaded%20to%20my%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3E%2Fmezzanine%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3EAzure%20storage%20container.%20But%20since%20media%20files%20usually%20are%20quite%20large%2C%20we%20need%20to%20ensure%20that%20the%20file%20is%20segmented%20in%20chunks.%20As%20recommended%20in%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fconnectors%2Fconnectors-create-api-azureblobstorage%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ethis%20article%3C%2FA%3E%2C%20the%20way%20is%20to%20use%20the%20%E2%80%9Cproperties%20only%E2%80%9D%20trigger%20and%20then%20use%20an%20additional%20Get%20blob%20content%20action.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2220200529-MediaUploadWorkflow-blobtrigger%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F213024iECF824F779E3D246%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%2220200529-MediaUploadWorkflow-blobtrigger%22%20alt%3D%2220200529-MediaUploadWorkflow-blobtrigger%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2220200529-MediaUploadWorkflow-getblobcontent%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F213025i079BF34B7E016BF1%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%2220200529-MediaUploadWorkflow-getblobcontent%22%20alt%3D%2220200529-MediaUploadWorkflow-getblobcontent%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId--1039758216%22%20id%3D%22toc-hId--1039758216%22%3ECreate%20an%20Asset%20in%20Azure%20Media%20Services%3C%2FH4%3E%0A%3CP%3EInterestingly%2C%20AMSv3%2C%20at%20this%20point%2C%20does%20not%20have%20a%20quick%20API%20call%20to%20convert%20a%20file%20into%20a%20recognized%20media%20asset.%20The%20process%20is%20first%20to%20create%20an%20%E2%80%9Cempty%20asset%E2%80%9D%20and%20then%20copy%20the%20blob%20content%20over.%20The%20process%20looks%20like%20this%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2220200529-MediaUploadWorkflow-createasset%22%20style%3D%22width%3A%20353px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F213026iFD39FEBAB94D62DD%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%2220200529-MediaUploadWorkflow-createasset%22%20alt%3D%2220200529-MediaUploadWorkflow-createasset%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3ENote%20that%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fraffertyuy%2Fmedia-services-v3-dotnet-core-functions-integration%2Fblob%2Fmaster%2Fadvanced-vod-workflow%2FFunctions%2FCreateEmptyAsset.cs%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ECreateEmptyAsset%3C%2FA%3E%2C%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fraffertyuy%2Fmedia-services-v3-dotnet-core-functions-integration%2Fblob%2Fmaster%2Fadvanced-vod-workflow%2FFunctions%2FStartBlobContainerCopyToAsset.cs%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EStartBlobContainerCopyToAsset%3C%2FA%3E%2C%20and%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fraffertyuy%2Fmedia-services-v3-dotnet-core-functions-integration%2Fblob%2Fmaster%2Fadvanced-vod-workflow%2FFunctions%2FMonitorBlobContainerCopyStatus.cs%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EMonitorBlobContainerCopyStatus%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eare%20Azure%20Functions.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId-1447754617%22%20id%3D%22toc-hId-1447754617%22%3ETranscode%20the%20Asset%20into%20Multi-bitrate%3C%2FH4%3E%0A%3CP%3EAzure%20Media%20Services%20has%20out-of-the-box%20presents%20for%20us%20to%20do%20our%20tests%2C%20but%20in%20a%20real-world%20scenario%2C%20a%20media%20company%20will%20likely%20have%20their%20custom-defined%20list%20of%20transcoding%20profiles.%20In%20this%20sample%20implementation%2C%20I%20used%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3EH264MultipleBitrate1080%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Epreset.%20I%20then%20created%20a%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CEM%3ETransform%3C%2FEM%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E(if%20it%20doesn%E2%80%99t%20yet%20exist)%20and%20then%20submitted%20a%20job%20for%20transcoding.%20You%20may%20refer%20to%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fmedia-services%2Flatest%2Ftransforms-jobs-concept%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ethis%20article%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%20understand%20these%20concepts%20better.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2220200529-MediaUploadWorkflow-transcode%22%20style%3D%22width%3A%20448px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F213027i1875E73234C915EF%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%2220200529-MediaUploadWorkflow-transcode%22%20alt%3D%2220200529-MediaUploadWorkflow-transcode%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3ESo%20I%20used%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fraffertyuy%2Fmedia-services-v3-dotnet-core-functions-integration%2Fblob%2Fmaster%2Fadvanced-vod-workflow%2FFunctions%2FCreateTransform.cs%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ECreateTransform%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eand%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fraffertyuy%2Fmedia-services-v3-dotnet-core-functions-integration%2Fblob%2Fmaster%2Fadvanced-vod-workflow%2FFunctions%2FSubmitMediaJob.cs%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ESubmitMediaJob%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Efunctions%20here.%20If%20you%20are%20planning%20to%20modify%20this%20logic%20app%20to%20suit%20your%20needs%2C%20you%20may%20need%20to%20spend%20some%20time%20understanding%20how%20to%20use%20these%20functions.%20In%20this%20logic%20app%2C%20this%20is%20where%20I%20spent%20most%20of%20my%20time.%20The%20sample%20code%20isn%E2%80%99t%20very%20well%20documented%20and%20not%20bug-free%20(As%20previously%20stated%2C%20this%20is%20a%20forked%20repo%20from%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure-Samples%2Fmedia-services-v3-dotnet-core-functions-integration%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzureSamples%3C%2FA%3E)%2C%20so%20it%20required%20a%20lot%20of%20trial-and-error%20and%20bug%20fixing.%3C%2FP%3E%0A%3CP%3EIf%20you%20are%20planning%20to%20create%20a%20new%20custom%20preset%2C%20you%20need%20to%20set%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3E%22preset%22%3A%20%22CustomPreset%22%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eand%20then%20define%20a%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3E%22customPresetJson%22%3A%20%7B...%7D%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eaccording%20to%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Frest%2Fapi%2Fmedia%2Ftransforms%2Fcreateorupdate%23standardencoderpreset%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ethis%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3EAfter%20the%20asset%20is%20transcoded%2C%20I%20then%20move%20the%20asset%20to%20another%20blob%20container.%20Since%20there%20is%20no%20%E2%80%9Cmove%E2%80%9D%20action%2C%20I%20had%20to%20create%20in%20the%20destination%20container%20first%2C%20and%20then%20delete%20the%20original%20one.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2220200529-MediaUploadWorkflow-moveblob%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F213028i310C0076A8DDFFA5%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%2220200529-MediaUploadWorkflow-moveblob%22%20alt%3D%2220200529-MediaUploadWorkflow-moveblob%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId--359699846%22%20id%3D%22toc-hId--359699846%22%3ESend%20to%20Azure%20Video%20Indexer%3C%2FH4%3E%0A%3CP%3EParallel%20to%20transcoding%2C%20I%20added%20another%20branch%20for%20sending%20the%20file%20to%20Video%20Indexer.%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fservices%2Fmedia-services%2Fvideo-indexer%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Video%20Indexer%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eis%20the%20media%20service%20AI%20solution%20for%20extracting%20more%20insights%20such%20as%20the%20transcripts%2C%20keywords%2C%20sentiments%2C%20celebrities%2C%20landmarks%2C%20etc.%20that%20are%20found%20in%20the%20media%20asset.%3C%2FP%3E%0A%3CP%3EIn%20uploading%2C%20you%20may%20choose%20to%20upload%20from%20a%20blob%20URL%20straight.%20But%20since%20we%20already%20have%20a%20media%20asset%2C%20I%20went%20with%20the%20Asset%20ID%20parameter%20option.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2220200529-MediaUploadWorkflow-videoindexer%22%20style%3D%22width%3A%20931px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F213029iA53E8DDF55BFBBA7%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%2220200529-MediaUploadWorkflow-videoindexer%22%20alt%3D%2220200529-MediaUploadWorkflow-videoindexer%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EOne%20interesting%20note%20here%20is%20that%20VI%20will%20transcode%20the%20asset%20again%20into%20a%20720p%20Single%20Bitrate%20file.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--370202950%22%20id%3D%22toc-hId--370202950%22%3EOutput%3C%2FH3%3E%0A%3CP%3EAnd%20here%20are%20the%20results%20after%20running%20this%20logic%20app%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId-320358524%22%20id%3D%22toc-hId-320358524%22%3EAzure%20Media%20Service%20Explorer%3C%2FH4%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2220200529-MediaUploadWorkflow-output-mediaserviceexplorer%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F213030i7CB093F8F111DF59%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%2220200529-MediaUploadWorkflow-output-mediaserviceexplorer%22%20alt%3D%2220200529-MediaUploadWorkflow-output-mediaserviceexplorer%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId--256225340%22%20id%3D%22toc-hId--256225340%22%3EMedia%20Asset%20in%20the%20Azure%20Storage%3C%2FH4%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2220200529-MediaUploadWorkflow-output-mediastorage%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F213031i22CBDCC9A8C3070B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%2220200529-MediaUploadWorkflow-output-mediastorage%22%20alt%3D%2220200529-MediaUploadWorkflow-output-mediastorage%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId--2063679803%22%20id%3D%22toc-hId--2063679803%22%3EInsights%20from%20Azure%20Video%20Indexer%3C%2FH4%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2220200529-MediaUploadWorkflow-output-videoindexer%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F213032i7DDE9D9702C9B60E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%2220200529-MediaUploadWorkflow-output-videoindexer%22%20alt%3D%2220200529-MediaUploadWorkflow-output-videoindexer%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2220200529-MediaUploadWorkflow-output-videoindexerview%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F213033i6B9F4247D03E11C9%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%2220200529-MediaUploadWorkflow-output-videoindexerview%22%20alt%3D%2220200529-MediaUploadWorkflow-output-videoindexerview%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-165667592%22%20id%3D%22toc-hId-165667592%22%3EPublish%20Asset%20for%20Streaming%3C%2FH2%3E%0A%3CP%3EPublishing%20an%20asset%20in%20this%20article%E2%80%99s%20definition%20is%20about%20creating%20a%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fmedia-services%2Flatest%2Fstreaming-locators-concept%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Estreaming%20locator%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eso%20that%20the%20asset%20is%20available%20for%20VOD.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1512704152%22%20id%3D%22toc-hId--1512704152%22%3EThe%20Logic%20App%3C%2FH3%3E%0A%3CP%3EThis%20is%20a%20pretty%20simple%20logic%20app%20and%20could%20have%20been%20combined%20with%20the%20previous%20one.%20But%20there%20are%20many%20reasons%20for%20not%20publishing%20an%20asset%20immediately%20after%20transcoding%20such%20as%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EChecking%20the%20quality%20of%20the%20video%2C%3C%2FLI%3E%0A%3CLI%3EAdding%20AES%20or%20DRM%20encryption%20policies%2C%3C%2FLI%3E%0A%3CLI%3EAdding%20closed%20captions%2C%3C%2FLI%3E%0A%3CLI%3Eand%20more%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3ESo%20to%20disconnect%2C%20I%20used%20an%20HTTP%20POST%20request%20to%20trigger%20this%20logic%20app%2C%20with%20the%20following%20JSON%20content-type%20body.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3E%7B%0A%20%20%20%20%22properties%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22alternative-media-id%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22string%22%0A%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%22assetName%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22string%22%0A%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%22contentKeyPolicyName%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22string%22%0A%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%22endDateTime%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22string%22%0A%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%22startDateTime%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22string%22%0A%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%22streamingEndpointName%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22string%22%0A%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%22streamingLocatorId%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22string%22%0A%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%22streamingPolicyName%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22string%22%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%22type%22%3A%20%22object%22%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EA%20simple%20request%20body%20will%20look%20like%20this%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3E%7B%0A%20%20%20%20%22assetName%22%3A%20%22MSIntelligentMedia-679c31f7-6cb1-47ad-bf92-080e19830c64%22%2C%0A%20%20%20%20%22streamingPolicyName%22%3A%20%22Predefined_ClearStreamingOnly%22%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EWith%20this%20HTTP%20request%2C%20it%20will%20be%20as%20simple%20as%20calling%20the%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fraffertyuy%2Fmedia-services-v3-dotnet-core-functions-integration%2Fblob%2Fmaster%2Fadvanced-vod-workflow%2FFunctions%2FPublishAsset.cs%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EPublishAsset%3C%2FA%3E%3CSPAN%3E%26nbsp%3Band%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fraffertyuy%2Fmedia-services-v3-dotnet-core-functions-integration%2Fblob%2Fmaster%2Fadvanced-vod-workflow%2FFunctions%2FGetAssetUrls.cs%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EGetAssetUrls%3C%2FA%3E%3CSPAN%3E%26nbsp%3BAzure%20Functions.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2220200529-MediaPublishWorkflow-logicapp%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F213034iBBC1F583191D0734%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%2220200529-MediaPublishWorkflow-logicapp%22%20alt%3D%2220200529-MediaPublishWorkflow-logicapp%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-974808681%22%20id%3D%22toc-hId-974808681%22%3EOutput%3C%2FH3%3E%0A%3CP%3EThis%20HTTP%20request%20will%20give%20me%20the%20following%20output.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2220200529-MediaPublishWorkflow-response%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F213035i2881D46064C07012%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%2220200529-MediaPublishWorkflow-response%22%20alt%3D%2220200529-MediaPublishWorkflow-response%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--961728501%22%20id%3D%22toc-hId--961728501%22%3EConclusion%3C%2FH2%3E%0A%3CP%3EIn%20this%20post%2C%20we%20learned%20how%20to%20create%20an%20Upload-and-Publish%20workflow%20using%20Azure%20Logic%20Apps%20and%20Azure%20Functions.%20Azure%20Functions%20for%20calling%20the%20Azure%20Media%20Service%20APIs%20and%20Logic%20Apps%20to%20orchestrate%20the%20workflow.%20This%20post%20also%20shows%20that%20Azure%20Logic%20Apps%20is%20not%20just%20a%20low-code%2Fno-code%20tool.%20It%20is%20fully%20capable%20of%20integrating%20with%20your%20custom%20code.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EGitHub%20Repository%3A%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fraffertyuy%2Fmedia-services-v3-dotnet-core-functions-integration%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fraffertyuy%2Fmedia-services-v3-dotnet-core-functions-integration%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1595464%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EOver%20the%20last%20two%20months%2C%20I%E2%80%99ve%20engaged%20with%20a%20few%20media%20companies%20who%20wanted%20to%20learn%20how%20to%20integrate%20Azure%20Media%20Services%20into%20their%20workflow.%26nbsp%3B%3C%2FSPAN%3E-ERR%3AREF-NOT-FOUND-Azure%20Media%20Services%20(AMS)%3CSPAN%3E%26nbsp%3Boffers%20a%20whole%20range%20of%20media%20capabilities%20for%20content%20ingest%2C%20storage%2C%20transcoding%2C%20video%20AI%2C%20encryption%2C%20dynamic%20packaging%2C%20and%20delivery%20%E2%80%93%20be%20it%20for%20live%20streaming%20or%20VOD%20through%20a%20single%20or%20multi-CDN.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1595464%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EApplication%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EIntegration%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

Over the last two months, I’ve engaged with a few media companies who wanted to learn how to integrate Azure Media Services into their workflow. Azure Media Services (AMS) offers a whole range of media capabilities for content ingest, storage, transcoding, video AI, encryption, dynamic packaging, and delivery – be it for live streaming or VOD through a single or multi-CDN.

 

20200529-MediaUploadWorkflow-AzureMediaServices

 

This post contains 2 sample workflow implementations for content ingest and clear stream publishing

  1. A logic app that monitors newly uploaded content in an Azure Storage for transcoding and indexing.
  2. A logic app for publishing a media asset with a clear stream locator.

 

Reference and Set-up

Before I start, let me just share first that I referred to these 2 GitHub Repos extensively in implementing this logic app:

In doing so, I had to refactor some functions and split them into two. I also had to add some more functions to suit my needs. So I forked the v3 repository, which you can check out here: https://github.com/raffertyuy/media-services-v3-dotnet-core-functions-integration.

Create an Azure Function App and deploy the functions found in the advanced-vod-workflow folder.

Also, if you prefer to skip reading the logic app documentation below, feel free to clone the repo above and go straight to the code.

 

Upload and Process Workflow

Media companies will have an existing process for the creation of mezzanine files. These files are then typically uploaded to a CDN for content distribution. Given that this process already exists, the idea here is to add/modify the upload destination to an Azure Storage instead and expect it to be processed in Azure Media Services.

 

Media Service Assets

An Asset is a core concept specific to Azure Media Services (AMS). It is not a single blob in Azure Storage. An asset from a storage perspective will contain multiple files, such as its metadata, multiple bitrate files, etc. Internally, AMS handles this by mapping each asset to an Azure Blob container, which contains all of these files.

So the main challenge is how to upload a mezzanine file and get it recognized as a media asset by Azure Media Services, and this is where logic apps come in.

 

The Logic App

Azure Logic Apps is a cloud service that helps you schedule, automate, and orchestrate tasks, business processes, and workflows when you need to integrate apps, data, systems, and services across enterprises or organizations. In this particular case, we are using logic apps to:

  1. Monitor an Azure Storage account for new uploads
  2. Create an Asset in Azure Media Services
  3. Transcode the asset into multi-bitrate
  4. Send to Azure Video Indexer for Video AI insights

In implementing this logic app, I used a lot of connectors, including a connector to Azure Functions. I used Azure functions to execute code that is not available in Logic Apps.

 

Monitor an Azure Storage Account for New Uploads

This one is easy; I used the Azure Blob Storage trigger to monitor for new files uploaded to my /mezzanine Azure storage container. But since media files usually are quite large, we need to ensure that the file is segmented in chunks. As recommended in this article, the way is to use the “properties only” trigger and then use an additional Get blob content action.

 

20200529-MediaUploadWorkflow-blobtrigger

20200529-MediaUploadWorkflow-getblobcontent

 

Create an Asset in Azure Media Services

Interestingly, AMSv3, at this point, does not have a quick API call to convert a file into a recognized media asset. The process is first to create an “empty asset” and then copy the blob content over. The process looks like this:

20200529-MediaUploadWorkflow-createasset

Note that CreateEmptyAsset, StartBlobContainerCopyToAsset, and MonitorBlobContainerCopyStatus are Azure Functions.

 

Transcode the Asset into Multi-bitrate

Azure Media Services has out-of-the-box presents for us to do our tests, but in a real-world scenario, a media company will likely have their custom-defined list of transcoding profiles. In this sample implementation, I used the H264MultipleBitrate1080 preset. I then created a Transform (if it doesn’t yet exist) and then submitted a job for transcoding. You may refer to this article to understand these concepts better.

20200529-MediaUploadWorkflow-transcode

So I used the CreateTransform and SubmitMediaJob functions here. If you are planning to modify this logic app to suit your needs, you may need to spend some time understanding how to use these functions. In this logic app, this is where I spent most of my time. The sample code isn’t very well documented and not bug-free (As previously stated, this is a forked repo from AzureSamples), so it required a lot of trial-and-error and bug fixing.

If you are planning to create a new custom preset, you need to set "preset": "CustomPreset" and then define a "customPresetJson": {...} according to this.

After the asset is transcoded, I then move the asset to another blob container. Since there is no “move” action, I had to create in the destination container first, and then delete the original one.

20200529-MediaUploadWorkflow-moveblob

 

Send to Azure Video Indexer

Parallel to transcoding, I added another branch for sending the file to Video Indexer. Azure Video Indexer is the media service AI solution for extracting more insights such as the transcripts, keywords, sentiments, celebrities, landmarks, etc. that are found in the media asset.

In uploading, you may choose to upload from a blob URL straight. But since we already have a media asset, I went with the Asset ID parameter option.

20200529-MediaUploadWorkflow-videoindexer

One interesting note here is that VI will transcode the asset again into a 720p Single Bitrate file.

 

Output

And here are the results after running this logic app

 

Azure Media Service Explorer

20200529-MediaUploadWorkflow-output-mediaserviceexplorer

 

Media Asset in the Azure Storage

20200529-MediaUploadWorkflow-output-mediastorage

 

Insights from Azure Video Indexer

20200529-MediaUploadWorkflow-output-videoindexer

20200529-MediaUploadWorkflow-output-videoindexerview

 

Publish Asset for Streaming

Publishing an asset in this article’s definition is about creating a streaming locator so that the asset is available for VOD.

 

The Logic App

This is a pretty simple logic app and could have been combined with the previous one. But there are many reasons for not publishing an asset immediately after transcoding such as:

  • Checking the quality of the video,
  • Adding AES or DRM encryption policies,
  • Adding closed captions,
  • and more

So to disconnect, I used an HTTP POST request to trigger this logic app, with the following JSON content-type body.

 

 

{
    "properties": {
        "alternative-media-id": {
            "type": "string"
        },
        "assetName": {
            "type": "string"
        },
        "contentKeyPolicyName": {
            "type": "string"
        },
        "endDateTime": {
            "type": "string"
        },
        "startDateTime": {
            "type": "string"
        },
        "streamingEndpointName": {
            "type": "string"
        },
        "streamingLocatorId": {
            "type": "string"
        },
        "streamingPolicyName": {
            "type": "string"
        }
    },
    "type": "object"
}

 

 

A simple request body will look like this:

 

 

{
    "assetName": "MSIntelligentMedia-679c31f7-6cb1-47ad-bf92-080e19830c64",
    "streamingPolicyName": "Predefined_ClearStreamingOnly"
}

 

 

With this HTTP request, it will be as simple as calling the PublishAsset and GetAssetUrls Azure Functions.

20200529-MediaPublishWorkflow-logicapp

 

Output

This HTTP request will give me the following output.

20200529-MediaPublishWorkflow-response

 

Conclusion

In this post, we learned how to create an Upload-and-Publish workflow using Azure Logic Apps and Azure Functions. Azure Functions for calling the Azure Media Service APIs and Logic Apps to orchestrate the workflow. This post also shows that Azure Logic Apps is not just a low-code/no-code tool. It is fully capable of integrating with your custom code.

 

GitHub Repository: https://github.com/raffertyuy/media-services-v3-dotnet-core-functions-integration