Skip to content

Instantly share code, notes, and snippets.

@fabriciosanchez
Created October 31, 2019 02:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabriciosanchez/f9cd363e7ab00d33d8bfc24c4fe2ae3a to your computer and use it in GitHub Desktop.
Save fabriciosanchez/f9cd363e7ab00d33d8bfc24c4fe2ae3a to your computer and use it in GitHub Desktop.
[FunctionName("A_PublishesEncodedAsset")]
public static async Task<string> PublishesEncodedAsset([ActivityTrigger] string resultEncoding, TraceWriter log)
{
// Step 1: Create the context
AzureAdTokenCredentials tokenCredentials = new AzureAdTokenCredentials(_tenantDomain, new AzureAdClientSymmetricKey(_clientId, _clientSecret), AzureEnvironments.AzureCloudEnvironment);
var tokenProvider = new AzureAdTokenProvider(tokenCredentials);
_context = new CloudMediaContext(new Uri(_restApiUrl), tokenProvider);
string streamingUrl;
// Step 2: Builds the streaming url for the encoded and published asset
try
{
log.Info("Publishing the asset and building up the streaming url...");
streamingUrl = MediaServices.PublishAndBuildStreamingURLs(resultEncoding, _context); ;
log.Info("Done. Asset published.");
log.Info($"Public URL: {streamingUrl}");
}
catch (Exception)
{
return string.Empty;
}
return streamingUrl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment