Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit f8785b2

Browse files
authored
Merge pull request #13 from Azure-Samples/xpouyat-nov2020
Package update, migration to Functions v3 and .Net Core.
2 parents 5d0dae0 + 3ae8ef7 commit f8785b2

File tree

17 files changed

+129
-65
lines changed

17 files changed

+129
-65
lines changed

Encoding/Encoding/Encoding.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
</Content>
2121
</ItemGroup>
2222
<ItemGroup>
23-
<PackageReference Include="Microsoft.Azure.DocumentDB.Core" Version="2.2.2" />
24-
<PackageReference Include="Microsoft.Azure.Management.Media" Version="2.0.1" />
25-
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB" Version="3.0.3" />
26-
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.3" />
27-
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication" Version="2.3.7" />
23+
<PackageReference Include="Microsoft.Azure.DocumentDB.Core" Version="2.12.0" />
24+
<PackageReference Include="Microsoft.Azure.Management.Media" Version="3.0.2" />
25+
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB" Version="3.0.8" />
26+
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.11" />
27+
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication" Version="2.4.1" />
2828
</ItemGroup>
2929
<ItemGroup>
3030
<None Update="host.json">

Encoding/Encoding/VodFunctions/ffmpeg-encoding.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,14 @@
1717
*/
1818

1919
using System;
20-
using System.Collections.Generic;
2120
using System.Diagnostics;
2221
using System.IO;
2322
using System.Linq;
24-
using System.Net;
2523
using System.Threading.Tasks;
26-
using Encoding.Helpers;
2724
using Microsoft.AspNetCore.Http;
2825
using Microsoft.AspNetCore.Mvc;
29-
using Microsoft.Azure.Management.Media;
30-
using Microsoft.Azure.Management.Media.Models;
3126
using Microsoft.Azure.WebJobs;
3227
using Microsoft.Azure.WebJobs.Extensions.Http;
33-
using Microsoft.Extensions.Configuration;
3428
using Microsoft.Extensions.Logging;
3529
using Microsoft.WindowsAzure.Storage.Blob;
3630
using Newtonsoft.Json;

Encoding/Encoding/local.settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"IsEncrypted": false,
3+
"Values": {
4+
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
5+
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
6+
}
7+
}

Encoding/README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,29 @@ author: xpouyat
55
---
66

77
# Ffmpeg encoding with an Azure function
8-
This Visual Studio 2017 Solution exposes an Azure Function that encodes an Azure Storage blob with ffmpeg. [Azure Functions Premium plan](https://docs.microsoft.com/en-us/azure/azure-functions/functions-premium-plan
8+
9+
This Visual Studio 2019 Solution exposes an Azure Function that encodes an Azure Storage blob with ffmpeg. [Azure Functions Premium plan](https://docs.microsoft.com/en-us/azure/azure-functions/functions-premium-plan
910
) is recommended.
1011

11-
This Functions code is based on Azure Functions v2.
12+
This Functions code is based on Azure Functions v3.
13+
14+
## Fork and download a copy
1215

13-
### Fork and download a copy
1416
If not already done : fork the repo, download a local copy.
1517

16-
### Ffmpeg
18+
## Ffmpeg
19+
1720
Download ffmpeg from the Internet and copy ffmpeg.exe in \Encoding\Encoding\ffmpeg folder.
1821
In Visual Studio, open the file properties, "Build action" should be "Content", with "Copy to Output Direcotry" set to "Copy if newer".
1922

20-
### Publish the function to Azure
23+
## Publish the function to Azure
24+
2125
Open the solution with Visual Studio and publish the functions to Azure.
2226
It is recommended to use a **premium plan** to avoid functions timeout (Premium gives you 30 min and a more powerfull host).
2327
It is possible to [unbound run duration](https://docs.microsoft.com/en-us/azure/azure-functions/functions-premium-plan#longer-run-duration).
2428

2529
JSON input body of the function :
30+
2631
```json
2732
{
2833
"sasInputUrl":"https://mysasurlofthesourceblob",

LiveAndVodDRMOperationsV3/LiveAndVodDRMOperationsV3/Helpers/GenerateInfoHelpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static GeneralOutputInfo GenerateOutputInformation(ConfigWrapper config,
3939
{
4040
LiveEventName = liveEvent.Name,
4141
ResourceState = liveEvent.ResourceState.ToString(),
42-
VanityUrl = liveEvent.VanityUrl,
42+
VanityUrl = liveEvent.UseStaticHostname,
4343
Input = liveEvent.Input.Endpoints
4444
.Select(endPoint => new UrlEntry { Protocol = endPoint.Protocol, Url = endPoint.Url }).ToList(),
4545
InputACL = liveEvent.Input.AccessControl?.Ip.Allow

LiveAndVodDRMOperationsV3/LiveAndVodDRMOperationsV3/LiveAndVodDRMOperationsV3.csproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netstandard2.0</TargetFramework>
4-
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
3+
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
55
<AssemblyVersion>1.0.1.0</AssemblyVersion>
66
<Version>1.0.0</Version>
77
</PropertyGroup>
@@ -16,13 +16,13 @@
1616
</ItemGroup>
1717
<ItemGroup>
1818
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
19-
<PackageReference Include="Microsoft.Azure.DocumentDB.Core" Version="2.10.1" />
20-
<PackageReference Include="Microsoft.Azure.Management.Media" Version="2.0.4" />
21-
<PackageReference Include="Microsoft.Azure.Storage.Blob" Version="11.1.3" />
22-
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB" Version="3.0.5" />
19+
<PackageReference Include="Microsoft.Azure.DocumentDB.Core" Version="2.12.0" />
20+
<PackageReference Include="Microsoft.Azure.Management.Media" Version="3.0.2" />
21+
<PackageReference Include="Microsoft.Azure.Storage.Blob" Version="11.2.2" />
22+
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB" Version="3.0.8" />
2323
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="3.0.2" />
24-
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.6" />
25-
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication" Version="2.4.0" />
24+
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.11" />
25+
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication" Version="2.4.1" />
2626
</ItemGroup>
2727
<ItemGroup>
2828
<None Update="host.json">

LiveAndVodDRMOperationsV3/LiveAndVodDRMOperationsV3/LiveFunctions/create-live-event-output.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ public static async Task<IActionResult> Run(
377377
name: liveEventName,
378378
location: config.Region,
379379
description: "",
380-
vanityUrl: eventInfoFromCosmos.VanityUrl,
380+
useStaticHostname: eventInfoFromCosmos.VanityUrl,
381381
encoding: new LiveEventEncoding { EncodingType = LiveEventEncodingType.None },
382382
input: liveEventInput,
383383
preview: liveEventPreview,
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
11
{
2+
"version": "2.0",
3+
"logging": {
4+
"applicationInsights": {
5+
"samplingExcludedTypes": "Request",
6+
"samplingSettings": {
7+
"isEnabled": true
8+
}
9+
}
10+
}
211
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"IsEncrypted": false,
3+
"Values": {
4+
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
5+
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
6+
"AzureWebJobsDashboard": "UseDevelopmentStorage=true",
7+
"AadClientId": "value",
8+
"AadEndpoint": "https://login.microsoftonline.com",
9+
"AadSecret": "value",
10+
"AadTenantId": "value",
11+
"AccountName": "value",
12+
"ArmAadAudience": "https://management.core.windows.net/",
13+
"ArmEndpoint": "https://management.azure.com/",
14+
"Region": "value",
15+
"AzureRegion": "euwe",
16+
"ResourceGroup": "value",
17+
"ResourceGroupFinalName": "true",
18+
"SubscriptionId": "value",
19+
"IrdetoUserName": "value",
20+
"IrdetoPassword": "value",
21+
"IrdetoAccountId": "value",
22+
"IrdetoSoapService": "https://test.ott.irdeto.com/LiveDRMService/livedrmservice.asmx",
23+
"IrdetoPlayReadyLAURL": "https://test.ott.irdeto.com/licenseServer/playready/v1/customer/license?contentId={AlternativeMediaId}",
24+
"IrdetoWidevineLAURL": "https://test.ott.irdeto.com/licenseServer/widevine/v1/customer/license?contentId={AlternativeMediaId}",
25+
"IrdetoFairPlayLAURL": "skd://test.ott.irdeto.com/licenseServer/streaming/v1/customer/getckc?contentId={AlternativeMediaId}&keyId={ContentKeyId}",
26+
"IrdetoFairPlayCertificateUrl": "https://test.ott.irdeto.com/licenseServer/streaming/v1/customer/getcertificate?applicationId=stage",
27+
"LiveIngestAccessToken": "value",
28+
"CosmosDBAccountEndpoint": "value",
29+
"CosmosDBAccountKey": "value",
30+
"CosmosDB": "liveDRMStreaming",
31+
"CosmosCollectionSettings": "liveEventSettings",
32+
"CosmosCollectionOutputs": "liveEventOutputInfo",
33+
"CosmosCollectionVODAssets": "vodAssets",
34+
"CosmosCollectionStreamingPolicies": "streamingPolicies",
35+
"CosmosCollectionVODResources": "vodResources",
36+
"AllowClearStream": "true"
37+
}
38+
}

LiveAndVodDRMOperationsV3/README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ author: xpouyat
55
---
66

77
# Media Services v3 Dynamic Encryption with Irdeto license delivery service (Live and VOD)
8-
This Visual Studio 2017 Solution exposes several Azure functions that can be used to manage live streaming and VOD with DRM, using Irdeto back-end to deliver the licenses. The functions communicate with Irdeto backend using SOAP. Optionaly, a Cosmos database can be used to store the result of the functions, and to specify the settings of the live event(s) to be created : ArchiveWindow, baseStorageName, ACLs, autostart, Vanity URL mode.
8+
9+
This Visual Studio 2019 Solution exposes several Azure functions that can be used to manage live streaming and VOD with DRM, using Irdeto back-end to deliver the licenses. The functions communicate with Irdeto backend using SOAP. Optionaly, a Cosmos database can be used to store the result of the functions, and to specify the settings of the live event(s) to be created : ArchiveWindow, baseStorageName, ACLs, autostart, Vanity URL mode.
910

1011
Here are the list of functions available:
1112

1213
Live
14+
1315
- check-all-live-event-output
1416
- create-clear-streaming-locator
1517
- create-live-event-output
@@ -23,6 +25,7 @@ Live
2325
- update-settings
2426

2527
VOD
28+
2629
- check-blob-copy-to-asset-status
2730
- create-empty-asset
2831
- create-vtt-to-asset
@@ -38,14 +41,15 @@ VOD
3841
As an option, two AMS accounts and two Azure functions deployments can be created in two different Azure regions. An Azure function deployment could manage either AMS account. For this to work, it is needed that the AMS account names ended with 2 or 4 letters which defines the region (euwe/euno OR we/no). Resource group names could have the same convention name, or a single resource group name can be used (in that case, use ResourceGroupFinalName proporty set to a non empty string).
3942

4043
For Live, it is also possible to execute all operations in two regions at the same time. For example, the creation of a live event can be executed by the function into two different accounts simultaneously. In that case, the same live event name, ingest path, output locator name, output locator GUID, streaming policy name and DRM keys will be used ; all URLS will be similar (except the hostname, of course). To use this mode, pass the two regions to the create-live-event-output function. Example :
44+
4145
```json
4246
{
4347
"liveEventName": "Channel1",
4448
"azureRegion" : "euwe,euno"
4549
}
4650
```
4751

48-
This Media Services Functions code is based on AMS REST API v3 using Azure Functions v2.
52+
This Media Services Functions code is based on AMS REST API v3 using Azure Functions v3.
4953

5054
Overall architecture :
5155

@@ -55,22 +59,22 @@ Overall architecture :
5559

5660
### 1. Create an Azure Media Services account
5761

58-
Create a Media Services account in your subscription if don't have it already ([follow this article](https://docs.microsoft.com/en-us/azure/media-services/previous/media-services-portal-create-account)).
62+
Create a Media Services account in your subscription if don't have it already ([follow this article](https://docs.microsoft.com/en-us/azure/media-services/latest/create-account-howto?tabs=portal)).
5963

6064
### 2. Create a Service Principal
6165

62-
Create a Service Principal and save the password. It will be needed in step #4. To do so, go to the API tab in the account ([follow this article](https://docs.microsoft.com/en-us/azure/media-services/media-services-portal-get-started-with-aad#service-principal-authentication)).
66+
Create a Service Principal and save the password. It will be needed in step #4. To do so, go to the API tab in the account ([follow this article](https://docs.microsoft.com/en-us/azure/media-services/latest/access-api-howto?tabs=portal)).
6367

6468
### 3. Make sure the AMS streaming endpoint is started
6569

66-
To enable streaming, go to the Azure portal, select the Azure Media Services account which has been created, and start the default streaming endpoint ([follow this article](https://docs.microsoft.com/en-us/azure/media-services/previous/media-services-portal-vod-get-started#start-the-streaming-endpoint)).
70+
To enable streaming, go to the Azure portal, select the Azure Media Services account which has been created, and start the default streaming endpoint.
6771

6872
### 4. Deploy the Azure functions
73+
6974
If not already done : fork the repo, download a local copy. Open the solution with Visual Studio and publish the functions to Azure.
7075
It is recommended to use a **dedicated plan** to avoid functions timeout.
7176
The redirector function (with anonymous access), if used, should be deployed on a separate plan as a **consumption plan** to get better scalability if this function is called by end-users.
7277

73-
7478
These functions have been designed to work with Irdeto back-end. It requires credentials and urls to be set in application settings. If you run the functions locally, you need to specify the values in the local settings file.
7579

7680
local.settings.json will look like (please replace 'value' with the correct data):
@@ -80,6 +84,7 @@ local.settings.json will look like (please replace 'value' with the correct data
8084
"IsEncrypted": false,
8185
"Values": {
8286
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
87+
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
8388
"AzureWebJobsDashboard": "UseDevelopmentStorage=true",
8489
"AadClientId": "value",
8590
"AadEndpoint": "https://login.microsoftonline.com",
@@ -109,7 +114,6 @@ local.settings.json will look like (please replace 'value' with the correct data
109114
"CosmosCollectionOutputs": "liveEventOutputInfo", // optional but needed for storing the output to Cosmos
110115
"CosmosCollectionVODAssets": "vodAssets", // optional but needed for storing the asset info to Cosmos
111116
"CosmosCollectionStreamingPolicies": "streamingPolicies", // optional but needed for storing the streaming policy to Cosmos
112-
"CosmosCollectionVODAssets": "vodAssets",
113117
"CosmosCollectionVODResources": "vodResources",
114118
"AllowClearStream" : "true" // optional, use only by redirector
115119
}
@@ -121,6 +125,7 @@ This database is used to read the settings when creating a live event. It is als
121125
Database and collections are automatically created by the code if Cosmos fields are set in app settings. Collections use a partition key named "/partitionKey" and value is always "live".
122126

123127
Example of settings in Cosmos for a live event :
128+
124129
```json
125130
{
126131
"liveEventName": "TESTLIVEEVENT",
@@ -149,6 +154,7 @@ Example of settings in Cosmos for a live event :
149154
```
150155

151156
Example of information in Cosmos for a live event :
157+
152158
```json
153159
{
154160
"liveEventName": "CH1",
@@ -277,4 +283,3 @@ Example of information in Cosmos for a live event :
277283
]
278284
}
279285
```
280-

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,26 @@ description: "Projects that show how to integrate Azure Media Services with Azur
1111
azureDeploy: https://raw.githubusercontent.com/Azure-Samples/media-services-v3-dotnet-core-functions-integration/master/azuredeploy.json
1212
---
1313

14-
# Azure Media Services v3 - Serverless Workflows with Azure Functions & Logic Apps
14+
# Azure Media Services v3 - Serverless Workflows with Azure Functions & Logic Apps
15+
1516
This repository contains projects that show how to integrate Azure Media Services with Azure Functions & Azure Logic Apps.
16-
These Media Services Functions examples are based on AMS REST API v3 on Azure Functions v2. Most of the functions can also be used from Logic Apps.
17+
These Media Services Functions examples are based on AMS REST API v3 on Azure Functions v3. Most of the functions can also be used from Logic Apps.
1718

1819
This repository can be accessed directly using https://aka.ms/ams3functions.
1920

2021
## Prerequisites for a sample Logic Apps deployments
2122

2223
### 1. Create an Azure Media Services account
2324

24-
Create a Media Services account in your subscription if don't have it already ([follow this article](https://docs.microsoft.com/en-us/azure/media-services/previous/media-services-portal-create-account)).
25+
Create a Media Services account in your subscription if don't have it already ([follow this article](https://docs.microsoft.com/en-us/azure/media-services/latest/create-account-howto?tabs=portal)).
2526

2627
### 2. Create a Service Principal
2728

28-
Create a Service Principal and save the password. It will be needed in step #4. To do so, go to the API tab in the account ([follow this article](https://docs.microsoft.com/en-us/azure/media-services/media-services-portal-get-started-with-aad#service-principal-authentication)).
29+
Create a Service Principal and save the password. It will be needed in step #4. To do so, go to the API tab in the account ([follow this article](https://docs.microsoft.com/en-us/azure/media-services/latest/access-api-howto?tabs=portal)).
2930

3031
### 3. Make sure the AMS streaming endpoint is started
3132

32-
To enable streaming, go to the Azure portal, select the Azure Media Services account which has been created, and start the default streaming endpoint ([follow this article](https://docs.microsoft.com/en-us/azure/media-services/previous/media-services-portal-vod-get-started#start-the-streaming-endpoint)).
33+
To enable streaming, go to the Azure portal, select the Azure Media Services account which has been created, and start the default streaming endpoint.
3334

3435
### 4. Deploy the Azure functions
3536

advanced-vod-workflow/Functions/MonitorBlobContainerCopyStatus.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,11 @@
5353
using Microsoft.Azure.Management.Media.Models;
5454
using Microsoft.Azure.WebJobs;
5555
using Microsoft.Azure.WebJobs.Extensions.Http;
56-
using Microsoft.Azure.WebJobs.Host;
57-
5856
using Microsoft.Extensions.Logging;
59-
60-
using Microsoft.WindowsAzure.Storage.Blob;
61-
6257
using Newtonsoft.Json;
6358
using Newtonsoft.Json.Linq;
64-
6559
using advanced_vod_functions_v3.SharedLibs;
66-
60+
using Microsoft.WindowsAzure.Storage.Blob;
6761

6862
namespace advanced_vod_functions_v3
6963
{

advanced-vod-workflow/Functions/StartBlobContainerCopyToAsset.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,17 @@
4242
using System.IO;
4343
using System.Linq;
4444
using System.Threading.Tasks;
45-
4645
using Microsoft.AspNetCore.Http;
4746
using Microsoft.AspNetCore.Mvc;
48-
4947
using Microsoft.Azure.Management.Media;
5048
using Microsoft.Azure.Management.Media.Models;
5149
using Microsoft.Azure.WebJobs;
5250
using Microsoft.Azure.WebJobs.Extensions.Http;
53-
using Microsoft.Azure.WebJobs.Host;
54-
5551
using Microsoft.Extensions.Logging;
56-
57-
using Microsoft.WindowsAzure.Storage.Blob;
58-
5952
using Newtonsoft.Json;
6053
using Newtonsoft.Json.Linq;
61-
6254
using advanced_vod_functions_v3.SharedLibs;
63-
55+
using Microsoft.WindowsAzure.Storage.Blob;
6456

6557
namespace advanced_vod_functions
6658
{

0 commit comments

Comments
 (0)