Azure Media Services: Can we create SAS tokens for streaming endpoints?

237 views Asked by At

I encoded a bunch of videos in Azure Media Services and created streaming endpoints. Everything works as expected. Now, I'd like to protect the endpoint URL for each video. For example, I'd like to make each URL available conditionally (for example up to an hour per user). Is it possible to define SAS tokens (similar to Azure Storage SAS tokens) for streaming endpoints? Or something similar that could do the job?

1

There are 1 answers

0
Jason Pan On

You can read offical doc first.

Tutorial: Use DRM dynamic encryption and license delivery service

After consulting the information, there should be no similar use of SAS to protect media resources. Generally, SAS is used to access resources in Storage.

In this tutorial, we specify for the content key policy to have a token restriction. The token-restricted policy must be accompanied by a token issued by a security token service (STS). Media Services supports tokens in the JWT formats and that's what we configure in the sample.

JwtSecurityToken token = new JwtSecurityToken(
    issuer: issuer,
    audience: audience,
    claims: claims,
    notBefore: DateTime.Now.AddMinutes(-5),
    expires: DateTime.Now.AddMinutes(60),
    signingCredentials: cred);

I think expires can meet your needs.

Build a streaming URL

// Look for just the DASH path and generate a URL for the Azure Media Player to playback the encrypted DASH content. 
// Note that the JWT token is set to expire in 1 hour. 
if (path.StreamingProtocol == StreamingPolicyStreamingProtocol.Dash)
{
    uriBuilder.Path = path.Paths[0];

    dashPath = uriBuilder.ToString();

}