This sample demonstrates how to dynamically encrypt your content with AES-128. It shows how to perform the following tasks:
- Creates a transform with built-in content aware encoding preset
- Submits a job
- Creates a ContentKeyPolicy using a secret key
- Associates the ContentKeyPolicy with StreamingLocator
- Gets a token and print a url for playback
When a stream is requested by a player, Media Services uses the specified key to dynamically encrypt your content with AES-128 and Azure Media Player uses the token to decrypt.
Required Assemblies:
- Azure.Identity
- Azure.ResourceManager.Media
- Microsoft.Extensions.Hosting
- Microsoft.IdentityModel.Tokens
- System.IdentityModel.Tokens.Jwt
- System.Security.Claims
An Azure Media Services account. See the steps described in Create a Media Services account.
Update the settings in appsettings.json in the root folder to match your Azure subscription, resource group and Media Services account. Then build and run the sample in Visual Studio or VS Code.
The sample will authenticate using any of the methods supported by DefaultAzureCredential
.