How to play an encrypted video through an API to MVC

Peter le Grand 21 Reputation points

I want to user Azure Media Services through the portal to upload videos and set the encryption policy there related to the locator.

Once done, I want to use an API and an MVC application both developed in .Net Core to show the video.

The video should be protected thus only be shown for users that are logged in. If they provide the video URL to someone else it should not be shown.

I was able to upload the videos, encode them, have a content policy, and create a locator related to the video and content policy.
I am able to create an API and MVC application.
I could store the URL of the video in a db that is used by the API.

But how do I show the encrypted video in the MVC app including?

Also, I tried it earlier with Blazor but couldn't get the video playing, even without encryption.
Most of the documentation I see is about how to develop video upload functionality, encryption, and locator creation. But that part I can do for now in the Azure portal.

Any suggestions?



Azure Media Services
Azure Media Services
A group of Azure services that includes encoding, format conversion, on-demand streaming, content protection, and live streaming services.
308 questions
A set of technologies in the .NET Framework for building web applications and XML web services.
4,227 questions
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,410 questions
{count} votes

1 answer

Sort by: Most helpful
  1. JasonPan - MSFT 4,386 Reputation points Microsoft Vendor

    Hi @Peter le Grand ,

    For best practices in azure media service, please refer to the official documentation.

    We recommend using azure media player to play videos. If you familiar with azure media player, you will get a good experience.

    From you description, we know you have save the media source url in your database, so we can generate the token to play the video.

    Reference Code:

    expires: DateTime.Now.AddMinutes(60),


    And the standard format of media source should like:

    not .

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards,

    0 comments No comments