/// <summary> /// Create the content key policy that configures how the content key is delivered to end clients /// via the Key Delivery component of Azure Media Services. /// </summary> /// <param name="client">The Media Services client.</param> /// <param name="resourceGroupName">The name of the resource group within the Azure subscription.</param> /// <param name="accountName"> The Media Services account name.</param> /// <param name="contentKeyPolicyName">The name of the content key policy resource.</param> /// <returns></returns> private static async Task <ContentKeyPolicy> GetOrCreateContentKeyPolicyAsync( IAzureMediaServicesClient client, ConfigWrapper config, string contentKeyPolicyName) { ContentKeyPolicy policy = await client.ContentKeyPolicies.GetAsync(config.ResourceGroup, config.AccountName, contentKeyPolicyName); if (policy == null) { ContentKeyPolicyOpenRestriction restriction = new ContentKeyPolicyOpenRestriction(); ContentKeyPolicyFairPlayConfiguration fairPlay = ConfigureFairPlayLicenseTemplate(config.AskHex, config.FairPlayPfxPath, config.FairPlayPfxPassword); List <ContentKeyPolicyOption> options = new List <ContentKeyPolicyOption> { new ContentKeyPolicyOption() { Configuration = fairPlay, Restriction = restriction } }; Console.WriteLine("Creating a content key policy..."); policy = await client.ContentKeyPolicies.CreateOrUpdateAsync(config.ResourceGroup, config.AccountName, contentKeyPolicyName, options); } return(policy); }
/// <summary> /// Create the content key policy that configures how the content key is delivered to end clients /// via the Key Delivery component of Azure Media Services. /// </summary> /// <param name="client">The Media Services client.</param> /// <param name="resourceGroupName">The name of the resource group within the Azure subscription.</param> /// <param name="accountName"> The Media Services account name.</param> /// <param name="contentKeyPolicyName">The name of the content key policy resource.</param> /// <returns></returns> private static async Task <ContentKeyPolicy> GetOrCreateContentKeyPolicyAsync( IAzureMediaServicesClient client, string resourceGroupName, string accountName, string contentKeyPolicyName) { ContentKeyPolicy policy = await client.ContentKeyPolicies.GetAsync(resourceGroupName, accountName, contentKeyPolicyName); if (policy == null) { ContentKeyPolicyOpenRestriction restriction = new ContentKeyPolicyOpenRestriction(); ContentKeyPolicyPlayReadyConfiguration playReadyConfig = ConfigurePlayReadyLicenseTemplate(); ContentKeyPolicyWidevineConfiguration widevineConfig = ConfigureWidevineLicenseTempate(); List <ContentKeyPolicyOption> options = new List <ContentKeyPolicyOption> { new ContentKeyPolicyOption() { Configuration = playReadyConfig, Restriction = restriction }, new ContentKeyPolicyOption() { Configuration = widevineConfig, Restriction = restriction } }; Console.WriteLine("Creating a content key policy..."); policy = await client.ContentKeyPolicies.CreateOrUpdateAsync(resourceGroupName, accountName, contentKeyPolicyName, options); } return(policy); }