Skip to content

gavinlefebvre/AMSLiveEventDRMDVR

Repository files navigation

topic languages products
sample
c#
azure-media-services

Live event with DRM & DVR

This sample demonstrates how to create and use LiveEvents and LiveOutputs in the v3 Media Services API. It performs the following tasks:

  1. Creates a pass-through LiveEvent.
  2. Starts monitoring the LiveEvent using Event Grid and Event Hub.
  3. Creates an Asset
  4. Creates a LiveOutput with 2 hours time span.
  5. Creates a StreamingLocator and associate the AssetFilter with it.
  6. Sets up PlayReady & Widevine policies
  7. Prints urls for the LiveEvent.
  8. Prints playback urls for the event archive after the LiveEvent stops.

Prerequisites

  • Required Assemblies
  • Microsoft.Azure.EventGrid -Version 3.2.0
  • Microsoft.Azure.EventHubs -Version 3.0.0
  • Microsoft.Azure.EventHubs.Processor -Version 3.0.0
  • Microsoft.Azure.Management.Media -Version 2.0.3
  • Microsoft.Extensions.Configuration -Version 2.1.1
  • Microsoft.Extensions.Configuration.EnvironmentVariables -Version 2.1.1
  • Microsoft.Extensions.Configuration.Json -Version 2.1.1
  • Microsoft.Rest.ClientRuntime.Azure.Authentication -Version 2.4.0
  • WindowsAzure.Storage -Version 9.3.3

Build and run

  • Enable Event Grid resource provider

    az provider register --namespace Microsoft.EventGrid

  • To check if registered, run the next command. You should see "Registered".

    az provider show --namespace Microsoft.EventGrid --query "registrationState"

  • Create an Event Hub

    namespace=<unique-namespace-name>
    hubname=<event-hub-name>
    az eventhubs namespace create --name $namespace --resource-group <resource-group>
    az eventhubs eventhub create --name $hubname --namespace-name $namespace --resource-group <resource-group>

  • Subscribe to Media Services events

    hubid=$(az eventhubs eventhub show --name $hubname --namespace-name $namespace --resource-group <resource-group> --query id --output tsv)
    amsResourceId=$(az ams account show --name <ams-account> --resource-group <resource-group> --query id --output tsv)
    az eventgrid event-subscription create --resource-id $amsResourceId --name <event-subscription-name> --endpoint-type eventhub --endpoint $hubid

  • Create a storage account and container for Event Processor Host if you don't have one https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-dotnet-standard-getstarted-send#create-a-storage-account-for-event-processor-host

  • Update appsettings.json with your Event Hub and Storage information StorageAccountName: The name of your storage account.
    StorageAccountKey: The access key for your storage account. In Azure portal "All resources", search your storage account, then click "Access keys", copy key1.
    StorageContainerName: The name of your container. Click Blobs in your storage account, find your container and copy the name.
    EventHubConnectionString: The Event Hub connection string. Search for the namespace you just created. <your namespace> -> Shared access policies -> RootManageSharedAccessKey -> Connection string-primary key.
    EventHubName: The Event Hub name. <your namespace> -> Event Hubs.

    Key concepts

Next steps

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages