/// <summary> /// Generates streaming locator using Azure Front Door URL /// This implementation is based on https://github.com/Azure-Samples/media-services-v3-dotnet-core-tutorials/tree/master/NETCore/EncodeHTTPAndPublishAESEncrypted /// </summary> /// <param name="client">Azure Media Services instance client</param> /// <param name="config">Azure Media Services instance configuration</param> /// <param name="locatorName">locator name</param> /// <param name="keyIdentifier">key identifier</param> /// <returns></returns> private async Task <string> GenerateStreamingUrl(IAzureMediaServicesClient client, MediaServiceConfigurationModel config, string locatorName, string keyIdentifier) { // Get token to access content var token = MediaServicesHelper.GetToken(this.configService.TokenIssuer, this.configService.TokenAudience, keyIdentifier, this.configService.GetClearKeyStreamingKey()); // Get list of all paths associated with specific locator var paths = await client.StreamingLocators.ListPathsAsync(config.ResourceGroup, config.AccountName, locatorName).ConfigureAwait(false); // Create Dash URL for (var i = 0; i < paths.StreamingPaths.Count; i++) { var uriBuilder = new UriBuilder(); uriBuilder.Scheme = "https"; uriBuilder.Host = this.configService.FrontDoorHostName; if (paths.StreamingPaths[i].Paths.Count > 0) { if (paths.StreamingPaths[i].StreamingProtocol == StreamingPolicyStreamingProtocol.Dash) { uriBuilder.Path = paths.StreamingPaths[i].Paths[0]; var dashPath = uriBuilder.ToString(); return($"https://ampdemo.azureedge.net/?url={dashPath}&aes=true&aestoken=Bearer%3D{token}"); } } } return(null); }